🌐 AI搜索 & 代理 主页
Skip to content

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