Repository navigation
Stop using deprecated ClassMetadata::getReflectionProperty() - #96
Merged
Merged
Conversation
Doctrine ORM 3.8 deprecates direct access to `ClassMetadata::$reflFields`, which will be removed in ORM 4.0. `getReflectionProperty()` is itself deprecated for the same reason, since it still reads from that array internally, so every call to it triggered a deprecation warning. Replace those calls with `ReflectionService::getAccessibleProperty()`, the same non-deprecated pattern this class already uses in `findTranslatedProperties()`. A naive replacement using the current class name broke properties declared in mapped superclasses, since PHP's `ReflectionProperty` cannot resolve a private property by name when given a subclass. The declaring class is now read from the field/association mapping's `declared` entry, mirroring what Doctrine does internally. Doctrine ORM 2 represents mappings as plain arrays rather than `FieldMapping`/`AssociationMapping` objects, so the helper handles both representations to keep working across the `doctrine/orm: ^2.13 || ^3.0` range this bundle supports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Doctrine ORM 3.8 deprecates direct access to
ClassMetadata::$reflFields. It will be removed in ORM 4.0, doctrine/orm#11659.ClassMetadata::getReflectionProperty()is itself deprecated for the same reason, since it still reads from that array internally.This PR replaces those calls with
ReflectionService::getAccessibleProperty(), the same non-deprecated pattern already used elsewhere inTranslatableClassMetadata.A naive replacement using the entity's own class name broke properties declared in mapped superclasses, since PHP's
ReflectionPropertycannot resolve a private property by name when given a subclass. The declaring class is now read from the field/association mapping'sdeclaredentry instead, mirroring what Doctrine does internally.