[PR #10450] Failing test: Duplicate private fields not detected #12375

Open
opened 2026-01-22 16:13:51 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/10450

State: closed
Merged: No


This has been merged through #10455.


This test case demonstrates two situations where an entity inherits from another entity or a mapped superclass. Both (parent and child) classes have a private property named field.

Technically, that's two properties on two separate classes. Also, the mapping configuration given suggests to put both properties into separate database columns.

However, the ORM was not designed to make this distinction. For example, ClassMetadata::$fieldMappings is indexed by "field name" – there is no room for juggling with duplicate private fields being declared in different classes. This design limitation that would be very hard to change, should be documented as a limitation and be rejected when it is noticed. The same applies to association mappings and embeddables.

Due to a quirk in the way the annotation and attribute drivers report fields (see #10417), the property will be skipped on the subclass. So, the property and mapping configuration will be picked up from the first (parent) class, and mapping configuration for GH10450ChildClass::$field will never be considered. The property will silently remain unmapped.

**Original Pull Request:** https://github.com/doctrine/orm/pull/10450 **State:** closed **Merged:** No --- This has been merged through #10455. <hr> This test case demonstrates two situations where an entity inherits from another entity or a mapped superclass. Both (parent and child) classes have a private property named `field`. Technically, that's two properties on two separate classes. Also, the mapping configuration given suggests to put both properties into separate database columns. However, the ORM was not designed to make this distinction. For example, `ClassMetadata::$fieldMappings` is indexed by "field name" – there is no room for juggling with duplicate private fields being declared in different classes. This design limitation that would be very hard to change, should be documented as a limitation and be rejected when it is noticed. The same applies to association mappings and embeddables. Due to a quirk in the way the annotation and attribute drivers report fields (see #10417), the property will be skipped on the subclass. So, the property and mapping configuration will be picked up from the first (parent) class, and mapping configuration for `GH10450ChildClass::$field` will never be considered. The property will silently remain unmapped.
admin added the pull-request label 2026-01-22 16:13:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12375