diff --git a/src/Util/ClassSourceManipulator.php b/src/Util/ClassSourceManipulator.php index 4db3191ca..6a9d86d93 100644 --- a/src/Util/ClassSourceManipulator.php +++ b/src/Util/ClassSourceManipulator.php @@ -110,7 +110,7 @@ public function addEntityField(string $propertyName, array $columnOptions, array $attributes[] = $this->buildAttributeNode(Column::class, $columnOptions, 'ORM'); $defaultValue = null; - if ('array' === $typeHint) { + if ('array' === $typeHint && !$nullable) { $defaultValue = new Node\Expr\Array_([], ['kind' => Node\Expr\Array_::KIND_SHORT]); } elseif ($typeHint && '\\' === $typeHint[0] && false !== strpos($typeHint, '\\', 1)) { $typeHint = $this->addUseStatementIfNecessary(substr($typeHint, 1));