Skip to content

Support Symfony Doctrine Bridge #27

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

Closed
curry684 opened this issue May 18, 2018 · 5 comments
Closed

Support Symfony Doctrine Bridge #27

curry684 opened this issue May 18, 2018 · 5 comments

Comments

@curry684
Copy link
Contributor

In Symfony's Doctrine bridge you 'must' inject Doctrine via the Symfony\Bridge\Doctrine\RegistryInterface:

    /** @var UserRepository */
    private $userRepository;

    public function __construct(RegistryInterface $registry)
    {
        $this->userRepository = $registry->getRepository(User::class);
    }

This code fails however with:

Property xxx::$userRepository (xxx\UserRepository) does not accept Doctrine\Common\Persistence\ObjectRepository.

@ondrejmirtes
Copy link
Member

ondrejmirtes commented May 19, 2018 via email

@curry684
Copy link
Contributor Author

Isn't this more or less exactly what #8 is doing, just via Symfony bridge? Seems all the code is already there.

@ondrejmirtes
Copy link
Member

ondrejmirtes commented May 19, 2018 via email

@ondrejmirtes
Copy link
Member

See how the relevant dynamic return type extensions are now registered in extension.neon:

	managerRegistryGetRepository:
		class: PHPStan\Type\Doctrine\GetRepositoryDynamicReturnTypeExtension
		tags:
			- phpstan.broker.dynamicMethodReturnTypeExtension
		arguments:
			managerClass: Doctrine\Common\Persistence\ManagerRegistry

	objectManagerGetRepository:
		class: PHPStan\Type\Doctrine\GetRepositoryDynamicReturnTypeExtension
		tags:
			- phpstan.broker.dynamicMethodReturnTypeExtension
		arguments:
			managerClass: Doctrine\Common\Persistence\ObjectManager

You can add another entry to your phpstan.neon with the right managerClass . I guess that's where the Symfony\Bridge\Doctrine\RegistryInterface belongs.

@github-actions
Copy link

github-actions bot commented May 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants