Skip to content

make:entity ManyToOne breaks if entities use Property HooksΒ #1716

@tacman

Description

@tacman

I'm getting an error with make:entity when an existing entity uses property hooks (note: Doctrine ORM 3.4 now supports them).

When I remove the property hook it works as expected.

        private(set) ?array $extra = null,
bin/console make:entity Image -v
Linting Generated Files With:
Bundled PHP-CS-Fixer & Bundled PHP-CS-Fixer Configuration

 Your entity already exists! So let's add some new fields!

 New property name (press <return> to stop adding fields):
 > product

 Field type (enter ? to see all types) [string]:
 > ManyToOne

 What class should this entity be related to?:
 > Product

 Is the Image.product property allowed to be null (nullable)? (yes/no) [yes]:
 > no 

 Do you want to add a new property to Product so that you can access/update Image objects from it - e.g. $product->getImages()? (yes/no) [yes]:
 > 

 A new property will also be added to the Product class so that you can access the related Image objects from it.

 New field name inside Product [images]:
 > 

 Do you want to activate orphanRemoval on your relationship?
 A Image is "orphaned" when it is removed from its related Product.
 e.g. $product->removeImage($image)
 
 NOTE: If a Image may *change* from one Product to another, answer "no".

 Do you want to automatically delete orphaned App\Entity\Image objects (orphanRemoval)? (yes/no) [no]:
 > yes


In ParserAbstract.php line 363:
                                                                                                
  [PhpParser\Error]                                                                             
  Syntax error, unexpected ')', expecting T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG on line 23  
                                                                                                

Exception trace:

The stack trace:

Exception trace:
  at /home/tac/sites/dummy/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:363
 PhpParser\ParserAbstract->doParse() at /home/tac/sites/dummy/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:187
 PhpParser\ParserAbstract->parse() at /home/tac/sites/dummy/vendor/symfony/maker-bundle/src/Util/ClassSourceManipulator.php:953
 Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator->setSourceCode() at /home/tac/sites/dummy/vendor/symfony/maker-bundle/src/Util/ClassSourceManipulator.php:76
 Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator->__construct() at /home/tac/sites/dummy/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php:849
 Symfony\Bundle\MakerBundle\Maker\MakeEntity->createClassManipulator() at /home/tac/sites/dummy/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php:254
 Symfony\Bundle\MakerBundle\Maker\MakeEntity->generate() at /home/tac/sites/dummy/vendor/symfony/maker-bundle/src/Command/MakerCommand.php:107
 Symfony\Bundle\MakerBundle\Command\MakerCommand->execute() at /home/tac/sites/dummy/vendor/symfony/console/Command/Command.php:318
 Symfony\Component\Console\Command\Command->run() at /home/tac/sites/dummy/vendor/symfony/console/Application.php:1092
 Symfony\Component\Console\Application->doRunCommand() at /home/tac/sites/dummy/vendor/symfony/framework-bundle/Console/Application.php:123
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/tac/sites/dummy/vendor/symfony/console/Application.php:341
 Symfony\Component\Console\Application->doRun() at /home/tac/sites/dummy/vendor/symfony/framework-bundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/tac/sites/dummy/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->run() at /home/tac/sites/dummy/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /home/tac/sites/dummy/vendor/autoload_runtime.php:29
 require_once() at /home/tac/sites/dummy/bin/console:11

make:entity [-a|--api-resource] [-b|--broadcast] [--regenerate] [--overwrite] [--with-uuid] [--with-ulid] [--] []

tac@system76-pc:~/sites/dummy$ c make:entity Image -v

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBug Fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions