-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Promoted constructor properties should not be doubled, fix #784 #785
base: 2.15.x
Are you sure you want to change the base?
Conversation
$method = parent::copyMethodSignature($reflectionMethod); | ||
|
||
foreach ($reflectionMethod->getParameters() as $reflectionParameter) { | ||
$method->setParameter( | ||
ParameterGenerator::fromReflection($reflectionParameter) | ||
); | ||
} | ||
|
||
return $method; |
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.
Shouldn't this behavior be fixed in laminas/laminas-code
, if we're required to copy parameter declarations twice to fix it?
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 think laminas-code does its best: it detects property promotion, and copies that as requested. But since we are doing inheritance, we dont need that. So problem on usage side, not on provider one.
Solution for laminas-code would be just to drop support of that feature of PHP, which is not the best, I think.
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.
There might be the another problem in laminas-code, since nullable flag are dropped in these promoted properties. But thats another issue. For doublers there should not be constructor property declarations anyways: they are already declared in base class.
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've created another issue for this (separate!) problem: laminas/laminas-code#183
Since properties are inherited, their declaration should not be doubled.
Issue arises with laminas-code versions, which supports constructor property promotion (at least 4.7, maybe earlier).
Closes #784
// cc @nicolas-grekas