Using @NamedArgumentConstructor is preferred way to define Annotations which also support PHP 8 Attributes. Instead of manually setting all properties based on $options argument, we should let doctrine/annotations take care about that.
This change actually allows us to force $mapping to be mandatory using native type checks. This also enables us to skip the name of the argument if it's not needed:
This however requires doctrine/annotations at v1.12 or higher. Not sure if we should add some checks for that. Perhaps adding it to conflicts section would be enough.
Update:
Removed deprecated PHPUnit usage of $this->at(). Tests are no longer depending on the order of method calls.
Using
@NamedArgumentConstructor
is preferred way to define Annotations which also support PHP 8 Attributes. Instead of manually setting all properties based on$options
argument, we should letdoctrine/annotations
take care about that.This change actually allows us to force
$mapping
to be mandatory using native type checks. This also enables us to skip the name of the argument if it's not needed:or
This however requires
doctrine/annotations
at v1.12 or higher. Not sure if we should add some checks for that. Perhaps adding it toconflicts
section would be enough.Update: Removed deprecated PHPUnit usage of
$this->at()
. Tests are no longer depending on the order of method calls.