mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #9001] Remove Proxy from EntityManagerInterface contract #11306
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/9001
State: closed
Merged: Yes
After merging #8922 by @simPod, I had a deeper look that the implementation to see if we can fix some of the newly baselined errors. I'd like to partially revert the change now. Sorry for the confusion.
#8922 added an intersection with the
Proxyinterface to the return type ofEntityManagerInterface::getReference()andgetPartialReference(). Here's why I now think that this is problematic:While our implementation
EntityManagermight return such an object, we cannot guarantee that it will. If you look at the following code snippet, you can see that the actual entity is returned instead of a reference, if the entity has already been registered with the UoW. In that case, the returned entity might not be a proxy object.04d28a9362/lib/Doctrine/ORM/EntityManager.php (L515-L520)If we kept the
Proxyinterface in the return type, the correct type would be(T&Proxy)|T|null.The
Proxyinterface is somewhat an implementation detail of ourEntityManagerimplementation that should not be leaked to the interface. I believe, the ORM should be able to move to a different proxy library without violating the contract ofEntityManagerInterface.