-
-
Notifications
You must be signed in to change notification settings - Fork 437
Description
Hello,
I'm able to reliably crash the make:entity command on 1.61 because of the following line:
maker-bundle/src/Doctrine/DoctrineHelper.php
Line 291 in ce60831
| return $returnType->isBuiltin() ? $returnType->getName() : '\\'.$returnType->getName(); |
As this helper relies on the convertToPHPValue return type (very clever btw) it will crash if the return value is set to mixed. This can be replicated with any custom doctrine type that is set in the application, with the following stack trace.
in BuilderHelpers.php line 208:
[LogicException]
mixed type cannot be nullable
Exception trace:
at /var/www/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php:208
PhpParser\BuilderHelpers::normalizeType() at /var/www/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php:127
PhpParser\Builder\Property->setType() at /var/www/vendor/symfony/maker-bundle/src/Util/ClassSourceManipulator.php:402
Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator->addProperty() at /var/www/vendor/symfony/maker-bundle/src/Util/ClassSourceManipulator.php:151
Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator->addEntityField() at /var/www/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php:243
Symfony\Bundle\MakerBundle\Maker\MakeEntity->generate() at /var/www/vendor/symfony/maker-bundle/src/Command/MakerCommand.php:102
Symfony\Bundle\MakerBundle\Command\MakerCommand->execute() at /var/www/vendor/symfony/console/Command/Command.php:326It appears that the builder tries to make a field with type mixed|null or ?mixed but mixed already implicitly includes null, which causes the error.
After updating the return type for our custom type from mixed to a more sensible string|null the error has stopped. Maybe in such a case a note should be printed to cli?