Skip to content

Commit c01ac62

Browse files
committed
bug #1293 [make:entity] don't set array field default value for nullable column (Rootie)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- [make:entity] don't set array field default value for nullable column Setting a default value will lead to a wrong (not nullable) return value of the getter method. Also setting a default value on a nullable field somehow cancels out the intention of nullable (except for setting it explicitly). I'm not sure if this should be treated as a bc break. but since no existing properties are overwritten i think it should be fine. Commits ------- 9c12187 [make:entity] don't set array field default value for nullable column
2 parents c283524 + 9c12187 commit c01ac62

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Util/ClassSourceManipulator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function addEntityField(string $propertyName, array $columnOptions, array
110110
$attributes[] = $this->buildAttributeNode(Column::class, $columnOptions, 'ORM');
111111

112112
$defaultValue = null;
113-
if ('array' === $typeHint) {
113+
if ('array' === $typeHint && !$nullable) {
114114
$defaultValue = new Node\Expr\Array_([], ['kind' => Node\Expr\Array_::KIND_SHORT]);
115115
} elseif ($typeHint && '\\' === $typeHint[0] && false !== strpos($typeHint, '\\', 1)) {
116116
$typeHint = $this->addUseStatementIfNecessary(substr($typeHint, 1));

0 commit comments

Comments
 (0)