Promoted constructor properties should not be doubled, fix #784#785
Promoted constructor properties should not be doubled, fix #784#785Grundik wants to merge 2 commits intoOcramius:2.15.xfrom
Conversation
| $method = parent::copyMethodSignature($reflectionMethod); | ||
|
|
||
| foreach ($reflectionMethod->getParameters() as $reflectionParameter) { | ||
| $method->setParameter( | ||
| ParameterGenerator::fromReflection($reflectionParameter) | ||
| ); | ||
| } | ||
|
|
||
| return $method; |
There was a problem hiding this comment.
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.
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.
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.
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