Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\Fixture;

class SkipAssignPlusCallByRefGlobal {
private array $fruits;

public function __construct() {
$this->fruits = ['banana', 'pear', 'apple'];
\sort($this->fruits);
}
}
7 changes: 4 additions & 3 deletions src/PhpParser/NodeFinder/PropertyFetchFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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) {
Expand Down