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

Do not use the return of include as an entity manager #2767

Closed
wants to merge 1 commit into from

Conversation

redthor
Copy link

@redthor redthor commented Feb 14, 2024

include returns 1 on success.

Did this ever work? Maybe a long time ago?

So I get:

PHP Fatal error:  Uncaught TypeError: Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider::__construct(): Argument #1 ($entityManager) must be of type Doctrine\ORM\EntityManagerInterface, int given, called in /home/douglas/Projects/r_DoctrineExtensions/example/bin/console.php on line 28 and defined in /home/douglas/Projects/r_DoctrineExtensions/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php:18
Stack trace:
#0 /home/douglas/Projects/r_DoctrineExtensions/example/bin/console.php(28): Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider->__construct()
#1 /home/douglas/Projects/r_DoctrineExtensions/example/bin/console(4): include('...')
#2 {main}
  thrown in /home/douglas/Projects/r_DoctrineExtensions/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php on line 18

easy to fix.

@@ -22,8 +22,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/** @var EntityManager $em */
$em = include __DIR__.'/../em.php';
include __DIR__.'/../em.php';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should add the missing return statement for the $em variable here:

$em = new EntityManager($connection, $config, $eventManager);

See include and the return statement.

@phansys
Copy link
Collaborator

phansys commented Aug 17, 2024

Thank you @redthor!

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

Successfully merging this pull request may close these issues.

2 participants