Allow reinitialization of a readonly property in __clone since PHP8.3#5731
Allow reinitialization of a readonly property in __clone since PHP8.3#5731grizzm0 wants to merge 1 commit into
Conversation
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
Signed-off-by: Kristofer Karlsson <karlsson.kristofer@gmail.com>
|
|
||
| $function = $scope->getFunction(); | ||
| if ( | ||
| $function instanceof MethodReflection |
There was a problem hiding this comment.
Is the instanceof MethodReflection really needed given the fact there is a previous $this->isInClass() check and you're checking the method name ?
There was a problem hiding this comment.
$function !== null
edit: Ohh I see now why it is done like that. we don't want to react on regular functions named __clone and we did similar checks across the codebase.
so its fine to me.
| } | ||
|
|
||
| $methodName = $scopeMethod->getName(); | ||
| $inClone = $this->phpVersion->supportsReadonlyPropertyReinitializationOnClone() && strtolower($methodName) === '__clone'; |
There was a problem hiding this comment.
Given the fact that CloneReinitializationExpr is only added if supportsReadonlyPropertyReinitializationOnClone is true, we might don't need to check it here again ?
There was a problem hiding this comment.
it seems check is still needed for the 1st occurence, which does not react on CloneReinitializationExpr
Fixes phpstan/phpstan#11495