Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony make entity command results in Exception #9669

Closed
snipershady opened this issue Apr 21, 2022 · 3 comments
Closed

Symfony make entity command results in Exception #9669

snipershady opened this issue Apr 21, 2022 · 3 comments

Comments

@snipershady
Copy link

Bug Report

Symfony make entity command results in Exception

Q A
BUG yes
Version 2.12

Summary

Symfony make entity command results in Exception

Current behavior

symfony console make:entity

[critical] Error thrown while running command "make:entity". Message: "Cannot access protected property Doctrine\ORM\Mapping\Driver\AttributeDriver::$classNames"

How to reproduce

  • Set up new Symfony project
  • Use doctrine/orm 2.12 package
  • run make:entity

Expected behavior

No exception

Temporary workaround

Downgrade
doctrine/orm to 2.11.2

@greg0ire
Copy link
Member

Please provide a stack trace

@snipershady
Copy link
Author

php bin/console make:entity --verbose

In DoctrineHelper.php line 187:
                                                                                              
  [Error]                                                                                     
  Cannot access protected property Doctrine\ORM\Mapping\Driver\AnnotationDriver::$classNames  
Exception trace:
  at /home/shady/public_html/mynewproject/vendor/symfony/maker-bundle/src/Doctrine/DoctrineHelper.php:187
 ReflectionProperty->setValue() at /home/shady/public_html/mynewproject/vendor/symfony/maker-bundle/src/Doctrine/DoctrineHelper.php:187
 Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper->getMetadata() at /home/shady/public_html/mynewproject/vendor/symfony/maker-bundle/src/Doctrine/DoctrineHelper.php:162
 Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper->getEntitiesForAutocomplete() at /home/shady/public_html/mynewproject/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php:515
 Symfony\Bundle\MakerBundle\Maker\MakeEntity->createEntityClassQuestion() at /home/shady/public_html/mynewproject/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php:116
 Symfony\Bundle\MakerBundle\Maker\MakeEntity->interact() at /home/shady/public_html/mynewproject/vendor/symfony/maker-bundle/src/Command/MakerCommand.php:99
 Symfony\Bundle\MakerBundle\Command\MakerCommand->interact() at /home/shady/public_html/mynewproject/vendor/symfony/console/Command/Command.php:276
 Symfony\Component\Console\Command\Command->run() at /home/shady/public_html/mynewproject/vendor/symfony/console/Application.php:1007
 Symfony\Component\Console\Application->doRunCommand() at /home/shady/public_html/mynewproject/vendor/symfony/framework-bundle/Console/Application.php:94
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/shady/public_html/mynewproject/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at /home/shady/public_html/mynewproject/vendor/symfony/framework-bundle/Console/Application.php:80
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/shady/public_html/mynewproject/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /home/shady/public_html/mynewproject/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /home/shady/public_html/mynewproject/vendor/autoload_runtime.php:29
 require_once() at /home/shady/public_html/mynewproject/bin/console:11

make:entity [-a|--api-resource] [-b|--broadcast] [--regenerate] [--overwrite] [--] [<name>]

@greg0ire
Copy link
Member

This should be reported to Symfony, and happens here: https://github.com/symfony/maker-bundle/blob/c5575532031eab8592ab6b1226e893b1a6b5bb0e/src/Doctrine/DoctrineHelper.php#L180-L187

It is caused by doctrine/persistence#246, but we cannot be held responsible by this as accessing protected properties through reflection is not really supposed to be supported. Also note the bug was revealed by something I'm probably going to have to revert in #9670 . So it might vanish in future versions, and come back later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants