Remove Proxy from EntityManagerInterface contract #9001
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Proxy
interface to the return type ofEntityManagerInterface::getReference()
andgetPartialReference()
. Here's why I now think that this is problematic:While our implementation
EntityManager
might 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.orm/lib/Doctrine/ORM/EntityManager.php
Lines 515 to 520 in 04d28a9
If we kept the
Proxy
interface in the return type, the correct type would be(T&Proxy)|T|null
.The
Proxy
interface is somewhat an implementation detail of ourEntityManager
implementation 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
.