Skip to content

Commit

Permalink
bug #1619 [make:entity] Issue with detected mixed type set to be null…
Browse files Browse the repository at this point in the history
…able (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
  • Loading branch information
kbond committed Dec 10, 2024
2 parents e712ed8 + 8bd85b5 commit fa367a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Util/ClassSourceManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function addEntityField(ClassProperty $mapping): void
}

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

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

Expand Down

0 comments on commit fa367a3

Please sign in to comment.