[PR #9531] Allow custom repository implementations to skip EntityRepository #11682

Closed
opened 2026-01-22 16:11:35 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/9531

State: closed
Merged: No


This change might be controversial.

Currently, the ORM requires repositories to be implementations of the generic ObjectRepository interface only. The ORM's own EntityRepository class is the default and can be used as base class for custom implementations, but we don't have to use it.

On the other hand, EntityManagerInterface::getRepository() promises to always return a EntityRepository. This works fine now, but will fail if we migrate to native return types.

This PR widens all return types to hint at the more generic ObjectRepository interface. It also adds a functional test that makes sure, generic ObjectRepository implementations can be used.

However, I'm unsure if using generic ObjectRepository implementations is a case that we actually want to support. The alternative could be to deprecate not using an EntityRepository sub-class and trigger an error on 3.0.

**Original Pull Request:** https://github.com/doctrine/orm/pull/9531 **State:** closed **Merged:** No --- This change might be controversial. Currently, the ORM requires repositories to be implementations of the generic `ObjectRepository` interface only. The ORM's own `EntityRepository` class is the default and can be used as base class for custom implementations, but we don't have to use it. On the other hand, `EntityManagerInterface::getRepository()` promises to always return a `EntityRepository`. This works fine now, but will fail if we migrate to native return types. This PR widens all return types to hint at the more generic `ObjectRepository` interface. It also adds a functional test that makes sure, generic `ObjectRepository` implementations can be used. However, I'm unsure if using generic `ObjectRepository` implementations is a case that we actually want to support. The alternative could be to deprecate not using an `EntityRepository` sub-class and trigger an error on 3.0.
admin added the pull-request label 2026-01-22 16:11:35 +01:00
admin closed this issue 2026-01-22 16:11:36 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#11682