diff --git a/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_assign_plus_call_by_ref_global.php.inc b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_assign_plus_call_by_ref_global.php.inc new file mode 100644 index 00000000000..5a8df7d2e61 --- /dev/null +++ b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_assign_plus_call_by_ref_global.php.inc @@ -0,0 +1,12 @@ +fruits = ['banana', 'pear', 'apple']; + \sort($this->fruits); + } +} diff --git a/src/PhpParser/NodeFinder/PropertyFetchFinder.php b/src/PhpParser/NodeFinder/PropertyFetchFinder.php index a6260a72719..8795a4e4c88 100644 --- a/src/PhpParser/NodeFinder/PropertyFetchFinder.php +++ b/src/PhpParser/NodeFinder/PropertyFetchFinder.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\Assign; +use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticCall; @@ -167,7 +168,7 @@ private function findPropertyFetchesInClassLike( $propertyFetches = $this->betterNodeFinder->find( $stmts, function (Node $subNode) use ($class, $hasTrait, $propertyName, $scope): bool { - if ($subNode instanceof MethodCall || $subNode instanceof StaticCall) { + if ($subNode instanceof MethodCall || $subNode instanceof StaticCall || $subNode instanceof FuncCall) { $this->decoratePropertyFetch($subNode, $scope); return false; } @@ -193,7 +194,7 @@ function (Node $subNode) use ($class, $hasTrait, $propertyName, $scope): bool { private function decoratePropertyFetch(Node $node, Scope $scope): void { - if (! $node instanceof MethodCall && ! $node instanceof StaticCall) { + if (! $node instanceof MethodCall && ! $node instanceof StaticCall && ! $node instanceof FuncCall) { return; } @@ -214,7 +215,7 @@ private function decoratePropertyFetch(Node $node, Scope $scope): void } } - private function isFoundByRefParam(MethodCall | StaticCall $node, int $key, Scope $scope): bool + private function isFoundByRefParam(MethodCall | StaticCall | FuncCall $node, int $key, Scope $scope): bool { $functionLikeReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); if ($functionLikeReflection === null) {