Skip to content

Commit 0d6fb63

Browse files
committed
fix
1 parent f209d77 commit 0d6fb63

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

rules/CodeQuality/Rector/ClassMethod/InlineArrayReturnAssignRector.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node\Expr\Array_;
99
use PhpParser\Node\Expr\ArrayDimFetch;
1010
use PhpParser\Node\Expr\Assign;
11+
use PhpParser\Node\Expr\Closure;
1112
use PhpParser\Node\Expr\New_;
1213
use PhpParser\Node\Expr\Variable;
1314
use PhpParser\Node\FunctionLike;
@@ -100,6 +101,18 @@ public function refactor(Node $node): ?Node
100101
return null;
101102
}
102103
}
104+
105+
if ($node instanceof Closure) {
106+
foreach ($node->uses as $use) {
107+
if (! $use->byRef) {
108+
continue;
109+
}
110+
111+
if ($this->isName($use->var, $returnedVariableName)) {
112+
return null;
113+
}
114+
}
115+
}
103116
}
104117

105118
$emptyArrayAssign = $this->resolveDefaultEmptyArrayAssign($stmts, $returnedVariableName);

0 commit comments

Comments
 (0)