Skip to content

Commit 8bd85b5

Browse files
committed
fix possible mixed type issue un class source manipulator
1 parent ce60831 commit 8bd85b5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: 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)