Skip to content

Commit fa367a3

Browse files
committed
bug #1619 [make:entity] Issue with detected mixed type set to be nullable (sadikoff)
This PR was merged into the 1.x-dev branch. Discussion ---------- [make:entity] Issue with detected mixed type set to be nullable Hi there, pretty strange edge case found in #1612 when `mixed` type is detected from a custom doctrine type and was set to be nullable. Maker tried to set is as `?mixed` which is not allowed. That should fix this behavior. closes #1612 Commits ------- 8bd85b5 fix possible mixed type issue un class source manipulator
2 parents e712ed8 + 8bd85b5 commit fa367a3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Util/ClassSourceManipulator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function addEntityField(ClassProperty $mapping): void
143143
}
144144

145145
$propertyType = $typeHint;
146-
if ($propertyType && !$defaultValue) {
146+
if ($propertyType && !$defaultValue && $propertyType !== 'mixed') {
147147
// all property types
148148
$propertyType = '?'.$propertyType;
149149
}
@@ -162,13 +162,13 @@ public function addEntityField(ClassProperty $mapping): void
162162
// getter methods always have nullable return values
163163
// because even though these are required in the db, they may not be set yet
164164
// unless there is a default value
165-
null === $defaultValue,
165+
null === $defaultValue && $propertyType !== 'mixed',
166166
$commentLines
167167
);
168168

169169
// don't generate setters for id fields
170170
if (!($mapping->id ?? false)) {
171-
$this->addSetter($mapping->propertyName, $typeHint, $nullable);
171+
$this->addSetter($mapping->propertyName, $typeHint, $nullable && $propertyType !== 'mixed');
172172
}
173173
}
174174

0 commit comments

Comments
 (0)