diff --git a/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php b/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php index 55590db391a..eacef23c6c5 100644 --- a/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php +++ b/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php @@ -162,20 +162,20 @@ private function isUselessBooleanAnd(BooleanAnd $booleanAnd, Expr $foreachExpr): return $this->countManipulator->isCounterHigherThanOne($booleanAnd->right, $foreachExpr); } - private function refactorStmtsAware(StmtsAwareInterface $stmtsAware): ?StmtsAwareInterface + private function refactorStmtsAware(Node $node): ?StmtsAwareInterface { - foreach ($stmtsAware->stmts as $key => $stmt) { + foreach ($node->stmts as $key => $stmt) { if (! $stmt instanceof If_) { continue; } - $nextStmt = $stmtsAware->stmts[$key + 1] ?? null; + $nextStmt = $node->stmts[$key + 1] ?? null; if (! $nextStmt instanceof Foreach_) { continue; } // the foreach must be the last one - if (isset($stmtsAware->stmts[$key + 2])) { + if (isset($node->stmts[$key + 2])) { continue; } @@ -186,8 +186,8 @@ private function refactorStmtsAware(StmtsAwareInterface $stmtsAware): ?StmtsAwar continue; } - unset($stmtsAware->stmts[$key]); - return $stmtsAware; + unset($node->stmts[$key]); + return $node; } return null;