Skip to content
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

Open
wants to merge 2 commits into
base: 2.15.x
Choose a base branch
from

Conversation

Grundik
Copy link

@Grundik Grundik commented May 16, 2023

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

Comment on lines +33 to +41
$method = parent::copyMethodSignature($reflectionMethod);

foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
$method->setParameter(
ParameterGenerator::fromReflection($reflectionParameter)
);
}

return $method;
Copy link
Owner

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?

Copy link
Author

@Grundik Grundik May 16, 2023

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.

Copy link
Author

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.

Copy link
Author

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

@Grundik Grundik requested a review from Ocramius May 16, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nullable constructor property promotion support
3 participants