Skip to content

Commit f8bda52

Browse files
committed
[DeadCode] Skip deep body walk when no removable assign in RemoveUnusedVariableAssignRector
1 parent 3ddaa09 commit f8bda52

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,15 @@ public function refactor(Node $node): null|ClassMethod|Function_
9494
return null;
9595
}
9696

97-
// we cannot be sure here
98-
if ($this->shouldSkip($stmts)) {
97+
$assignedVariableNamesByStmtPosition = $this->resolvedAssignedVariablesByStmtPosition($stmts);
98+
if ($assignedVariableNamesByStmtPosition === []) {
9999
return null;
100100
}
101101

102-
$assignedVariableNamesByStmtPosition = $this->resolvedAssignedVariablesByStmtPosition($stmts);
102+
// we cannot be sure here, deep walk only when there is a candidate to remove
103+
if ($this->shouldSkip($stmts)) {
104+
return null;
105+
}
103106

104107
$hasChanged = false;
105108

0 commit comments

Comments
 (0)