mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Add New Attribute Metadata Driver #6538
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @beberlei on GitHub (Sep 13, 2020).
Originally assigned to: @beberlei on GitHub.
For Doctrine ORM 2.8 we should add a metadata driver using Attributes, based off the AnnotationDriver with some adjustment to account for the missing nested support.
Idea:
Doctrine\ORM\Mapping\*annotation classes and add#[Attribute]as needed.@JoinTableby introducing newInverseJoinColumnattribute@Tableby allowingIndexandUniqueConstrainton the entity/class level.@beberlei commented on GitHub (Sep 13, 2020):
Problem with this approach is that without a constructor using parameters, IDEs will probably not autocomplete the named properties of attributes. This requires us to duplicate all attribute classes unless we find some clever magic, or adjust the Annotation DocParser case with
has_constructormust be changed or broken in some way.@lcobucci commented on GitHub (Sep 13, 2020):
Dropping named queries is a BC-break though
@beberlei commented on GitHub (Sep 13, 2020):
@lcobucci not for a new metadata driver
@lcobucci commented on GitHub (Sep 13, 2020):
Fair enough 👍
@beberlei commented on GitHub (Sep 13, 2020):
Currently Annotation
DocParserdoesnew $annotation($values);if a constructor is detected. This is based on theAnnotationbase class that existis in the library. We should have another use-case where it checks for constructor but not extendingDoctrine\Common\Annotations\Nnnotationand in that case replicate named arguments behavior:@Column(name="foo")maps to a constructor__construct($name).This is required so we can move all annotation classes to use a constructor in ORM 2.8.
@beberlei commented on GitHub (Sep 13, 2020):
The problem without this change is that we could not use
ReflectionAttribute::newInstancethen and also would probably confuse IDE autocomplete for attributes as they look for constructor arguments to suggest.@BenMorel commented on GitHub (Oct 13, 2020):
Looking forward to the attribute-based annotation driver! 👍
What's the issue with multiple
#[AssociationOverride()]on the entity directly? (I've never understood the need for@AssociationOverridesin the first place, maybe a limitation in Doctrine Annotations?)@beberlei commented on GitHub (Apr 16, 2021):
This is merged with #8266