EntityManagerInterface is missing getRepository definition #6335

Closed
opened 2026-01-22 15:31:13 +01:00 by admin · 1 comment
Owner

Originally created by @AngelsDustz on GitHub (Nov 5, 2019).

Originally assigned to: @Ocramius on GitHub.

Hello, we have some strict type checking on our PHP code and PHPStan noticed that I wrongly assigned a variable.

Upon further investigation I noticed that EntityManagerInterface->getRepository has a different specified return type than EntityManager->getRepository.

The non-interface has the following return annotation: ObjectRepository|EntityRepository (https://www.doctrine-project.org/api/orm/latest/Doctrine/ORM/EntityManager.html#method_getRepository)

But the interface does not have this function defined and defaults to the inherited ObjectManager->getRepository resulting in a return type of ObjectRepository.

Originally created by @AngelsDustz on GitHub (Nov 5, 2019). Originally assigned to: @Ocramius on GitHub. Hello, we have some strict type checking on our PHP code and PHPStan noticed that I wrongly assigned a variable. Upon further investigation I noticed that `EntityManagerInterface->getRepository` has a different specified return type than `EntityManager->getRepository`. The non-interface has the following return annotation: `ObjectRepository|EntityRepository` (https://www.doctrine-project.org/api/orm/latest/Doctrine/ORM/EntityManager.html#method_getRepository) But the interface does not have this function defined and defaults to the inherited `ObjectManager->getRepository` resulting in a return type of `ObjectRepository`.
admin added the Question label 2026-01-22 15:31:13 +01:00
admin closed this issue 2026-01-22 15:31:14 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 5, 2019):

But the interface does not have this function defined and defaults to the inherited ObjectManager->getRepository resulting in a return type of ObjectRepository.

This is correct and expected

@Ocramius commented on GitHub (Nov 5, 2019): > But the interface does not have this function defined and defaults to the inherited `ObjectManager->getRepository` resulting in a return type of `ObjectRepository`. This is correct and expected
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6335