-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use NamedArgumentConstructorAnnotation for annotations #2243
Conversation
{ | ||
/** @var string */ | ||
public $name; | ||
|
||
/** @var string */ | ||
public $type = 'string'; | ||
/** @var string|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|null
comes from @Id
/** @var string|string[] */ | ||
public $value; | ||
|
||
/** @var string|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to fix all the wrong docblocks by the way
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea for a later PR (or commit): add validation to ctors
{ | ||
/** @var string|null */ | ||
public $db; | ||
|
||
/** @var string|null */ | ||
/** @var array|string|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array
is used for capped collection's config
public $notSaved = true; | ||
public function __construct( | ||
string $name = 'chunkSize', | ||
string $type = 'int', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it even make sense to allow overriding anything but $name
here? Same goes for other File-related annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No: only the name can be configured, the rest is specified in the GridFS Specification.
@@ -35,7 +32,7 @@ final class ReferenceMany extends AbstractField | |||
/** @var string|null */ | |||
public $defaultDiscriminatorValue; | |||
|
|||
/** @var string[]|null */ | |||
/** @var string|string[]|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turns out using string is also fine, it's converted to an array later while mapping field
bbb2f29
to
45bfb60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general theme, I'd advocate to rename the $value
arguments in constructors to something more meaningful. For example, in the AlsoLoad
annotation, $value
doesn't really tell me what this should be, especially with $name
being the other field. This is especially true with these names being somewhat relevant to BC when people use named arguments.
* | ||
* @Annotation | ||
*/ | ||
final class Inheritance extends Annotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this class is final
and never checked for, it should be safe to remove it. I'm sure there's someone out there using it, not realising that it didn't do anything.
/** | ||
* Specifies a parent class that other documents may extend to inherit mapping | ||
* information | ||
* | ||
* @Annotation | ||
*/ | ||
final class MappedSuperclass extends AbstractDocument | ||
final class MappedSuperclass extends AbstractDocument implements NamedArgumentConstructorAnnotation | ||
{ | ||
/** @var string */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var string */ | |
/** @var string|null */ |
Getting back to the PR got me so long somebody opened doctrine/annotations#396 which actually is great :) |
Nah, let's close this one 👍 |
Brings doctrine/annotations#369 to the ODM, here's what can be done later: doctrine/orm#8266