Fix fields of transient classes being considered duplicate with reportFieldsWhereDeclared#11769
Conversation
…rtFieldsWhereDeclared`
|
Thanks @HypeMC ! |
|
I know I remained silent back in January 😉, so I am late to the party. Now while investigating #11488, I came across the change here and wonder whether it was the right thing to do. I think a transient class that is neither a This is clearly stated here:
The code added here in parts defeated the intention to make sure we can clearly trace back every field to an entity or mapped superclass. My feeling is that we should instead fail with a clear error message stating that a field was found that does not come from a mapped class, instead of somehow running into seemingly duplicate definitions. |
| /** @var class-string $declaringClass */ | ||
| $declaringClass = $property->class; | ||
|
|
||
| if ($this->isTransient($declaringClass)) { |
There was a problem hiding this comment.
One more issue here: This assumes that the same mapping driver that is working on $property can also judge whether $declaringClass is transient.
This may not work out e. g. when using different mapping drivers, for example mixing XML and attribute based configuration in different namespaces.
Example: The ReflectionBasedDriver will falsely assume that $declaringClass is transient when it is in fact mapped through XML.
Yes, this is what I would say as well. |
…th `reportFieldsWhereDeclared` (doctrine#11769)" This reverts commit 4feaa47.
|
I am suggesting to revert this change in #12212. |
Revert "Fix fields of transient classes being considered duplicate with `reportFieldsWhereDeclared` (#11769)"
When I enabled the
reportFieldsWhereDeclaredoption introduced in #10455, I encountered a problem when using transient classes. For example, the following code produces an error:To my understanding, this shouldn't happen since
AbstractEntityis a transient class. Perhaps @mpdude, as the original author, could shed some light on this.