Report invalid constructor property promotion for readonly props already defined in parent class constructor#1788
Report invalid constructor property promotion for readonly props already defined in parent class constructor#1788staabm wants to merge 3 commits intophpstan:1.8.xfrom
Conversation
…ady defined in parent class constructor
| $node->getName(), | ||
| ))->nonIgnorable()->build(); | ||
| } else { | ||
| $errors[] = RuleErrorBuilder::message(sprintf( |
There was a problem hiding this comment.
I was not able to come up with a similar example for the static case above this IF-block, therefore only added here.
There was a problem hiding this comment.
just read about 3e383fc which resolves my questions, as readonly properties cannot be static.
|
@herndlm do we need a similar fix for phpdoc based readonly properties? |
hmm, the phpdoc-based-readonly rules are basically duplicates of the native readonly ones. but there is no equivalent for |
|
I can't merge this, because it's allowed by PHP: https://3v4l.org/jPiT7 See: phpstan/phpstan#8101 (comment) We have to come up with a more clever fix for this. To realize that the property is already assigned (it's promoted) when calling the constructor. |
closes phpstan/phpstan#8101