AnnotationDriver handles field mappings differently #5066

Closed
opened 2026-01-22 14:57:36 +01:00 by admin · 2 comments
Owner

Originally created by @dylanschoenmakers on GitHub (Mar 29, 2016).

Originally assigned to: @ostrolucky on GitHub.

A problem with a mapped superclass led me to this piece of code that conditionally maps fields in the loadMetadataForClass method in the AnnotationDriver. See commit 09a48a896e

    public function loadMetadataForClass($className, ClassMetadata $metadata)
    {

        // Evaluate annotations on properties/fields
        /* @var $property \ReflectionProperty */
        foreach ($class->getProperties() as $property) {
            if ($metadata->isMappedSuperclass && ! $property->isPrivate()
                ||
                $metadata->isInheritedField($property->name)
                ||
                $metadata->isInheritedAssociation($property->name)
                ||
                $metadata->isInheritedEmbeddedClass($property->name)) {
                continue;
            }

Other drivers like yaml or xml don't have these conditions, or not that I can see. Does anyone have more information about this or has encountered the same problems with overriding field mappings with annotations?

Originally created by @dylanschoenmakers on GitHub (Mar 29, 2016). Originally assigned to: @ostrolucky on GitHub. A problem with a mapped superclass led me to this piece of code that conditionally maps fields in the `loadMetadataForClass` method in the AnnotationDriver. See commit 09a48a896eb3adfb1569beafab8566b69167b01e ``` php public function loadMetadataForClass($className, ClassMetadata $metadata) { … // Evaluate annotations on properties/fields /* @var $property \ReflectionProperty */ foreach ($class->getProperties() as $property) { if ($metadata->isMappedSuperclass && ! $property->isPrivate() || $metadata->isInheritedField($property->name) || $metadata->isInheritedAssociation($property->name) || $metadata->isInheritedEmbeddedClass($property->name)) { continue; } ``` Other drivers like yaml or xml don't have these conditions, or not that I can see. Does anyone have more information about this or has encountered the same problems with overriding field mappings with annotations?
admin closed this issue 2026-01-22 14:57:36 +01:00
Author
Owner

@ostrolucky commented on GitHub (Aug 6, 2018):

See referenced issue DDC-34 = https://github.com/doctrine/doctrine2/issues/4198

@ostrolucky commented on GitHub (Aug 6, 2018): See referenced issue DDC-34 = https://github.com/doctrine/doctrine2/issues/4198
Author
Owner

@mpdude commented on GitHub (Jan 25, 2023):

👀 needed regarding this in #10455

@mpdude commented on GitHub (Jan 25, 2023): 👀 needed regarding this in #10455
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5066