Add ClassMetadataFactoryInterface to allow switching implementation#11497
Add ClassMetadataFactoryInterface to allow switching implementation#11497alekitto wants to merge 1 commit intodoctrine:3.2.xfrom
Conversation
|
|
||
| <rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"> | ||
| <exclude-pattern>src/EntityManagerInterface.php</exclude-pattern> | ||
| <exclude-pattern>src/Mapping/ClassMetadataFactoryInterface.php</exclude-pattern> |
There was a problem hiding this comment.
Why was this excluded from phpcs checks? It's going to be a new interface that you can name without the superflous naming.
There was a problem hiding this comment.
Doctrine\ORM\Mapping\ClassMetadataFactory is already used (is the name of the current implementation).
Do you have a better proposal for the name of this interface?
| $reflectionClass = new ReflectionClass($cmfName); | ||
| if (! $reflectionClass->implementsInterface(ClassMetadataFactoryInterface::class)) { | ||
| throw InvalidClassMetadataFactory::create($cmfName); | ||
| } |
There was a problem hiding this comment.
This would introduce an exception when there was not one before.
There was a problem hiding this comment.
Prior to this PR a call with a class different from Doctrine\ORM\Mapping\ClassMetadataFactory would cause a TypeError. So yes, it would not throw an exception here, but in a different (and completely unrelated) point of the code, which can be harder to debug.
|
@SenseException any news on this? |
|
@alekitto can you explain what your use case is in overwriting the CMF this way? Just trying to asses what is the overall idea. Historically we didn't like overwriting any of the internal classes, which I would count the CMF. |
I already did that on the issue: #11496 (comment) I'm overriding the metadata factory with a mocked/fake version of it in unit tests, to precisely control what has been returned and test libraries and classes in isolation. The configuration object still allow to overwrite the class name of the class metadata factory, and I always used that in testing and, for example, to override the |
|
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
|
Not stale. Waiting for a response |
|
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
|
Not stale. Still waiting for a response. |
|
Sorry @greg0ire why this PR has been closed? |
|
Sorry, it was closed because I deleted the branch. Feel free to reopen against another branch. |
New Feature
Summary
Fixes #11496
This PR introduces a new
ClassMetadataFactoryInterfaceinterface and changes the type-hints to allow switching implementation of the factory in configuration.