diff --git a/.github/workflows/build_scoped_rector.yaml b/.github/workflows/build_scoped_rector.yaml index bbf3d9a734c..f77c34961af 100644 --- a/.github/workflows/build_scoped_rector.yaml +++ b/.github/workflows/build_scoped_rector.yaml @@ -58,7 +58,7 @@ jobs: # 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop - run: rsync --exclude rector-build -av * rector-build --quiet - - run: rm -rf rector-build/rules-tests rector-build/tests rector-build/bin/generate-changelog.php rector-build/bin/validate-phpstan-version.php rector-build/vendor/tracy/tracy/examples rector-build/vendor/symfony/console/Tester rector-build/vendor/symfony/console/Event rector-build/vendor/symfony/console/EventListener rector-build/vendor/tracy/tracy/examples rector-build/vendor/tracy/tracy/src/Bridges rector-build/vendor/tracy/tracy/src/Tracy/Bar rector-build/vendor/tracy/tracy/src/Tracy/Session rector-build/vendor/symfony/service-contracts/Test + - run: rm -rf rector-build/rules-tests rector-build/tests rector-build/bin/generate-changelog.php rector-build/bin/validate-phpstan-version.php rector-build/vendor/tracy/tracy/examples rector-build/vendor/symfony/console/Tester rector-build/vendor/symfony/console/Event rector-build/vendor/symfony/console/EventListener rector-build/vendor/tracy/tracy/examples rector-build/vendor/tracy/tracy/src/Bridges rector-build/vendor/tracy/tracy/src/Tracy/Bar rector-build/vendor/tracy/tracy/src/Tracy/Session rector-build/vendor/symfony/service-contracts/Test rector-build/bin/check-before-after-same-fixtures.php rector-build/bin/no-php-file-in-fixtures.php # 2. downgrade rector - run: php -d memory_limit=-1 bin/rector process rector-build/bin rector-build/config rector-build/src rector-build/rules rector-build/vendor --config build/config/config-downgrade.php --ansi --no-diffs diff --git a/rules/Php84/Rector/Foreach_/ForeachToArrayAnyRector.php b/rules/Php84/Rector/Foreach_/ForeachToArrayAnyRector.php index 3ff1f72a6b9..e3c349273a4 100644 --- a/rules/Php84/Rector/Foreach_/ForeachToArrayAnyRector.php +++ b/rules/Php84/Rector/Foreach_/ForeachToArrayAnyRector.php @@ -101,14 +101,14 @@ public function provideMinPhpVersion(): int return PhpVersionFeature::ARRAY_ANY; } - private function refactorBooleanAssignmentPattern(StmtsAwareInterface $node): ?Node + private function refactorBooleanAssignmentPattern(StmtsAwareInterface $stmtsAware): ?Node { - foreach ($node->stmts as $key => $stmt) { + foreach ($stmtsAware->stmts as $key => $stmt) { if (! $stmt instanceof Foreach_) { continue; } - $prevStmt = $node->stmts[$key - 1] ?? null; + $prevStmt = $stmtsAware->stmts[$key - 1] ?? null; if (! $prevStmt instanceof Expression) { continue; } @@ -135,7 +135,7 @@ private function refactorBooleanAssignmentPattern(StmtsAwareInterface $node): ?N } if ($this->stmtsManipulator->isVariableUsedInNextStmt( - $node, + $stmtsAware, $key + 1, (string) $this->getName($foreach->valueVar) )) { @@ -171,26 +171,26 @@ private function refactorBooleanAssignmentPattern(StmtsAwareInterface $node): ?N $newAssign = new Assign($assignedVariable, $funcCall); $newExpression = new Expression($newAssign); - unset($node->stmts[$key - 1]); - $node->stmts[$key] = $newExpression; + unset($stmtsAware->stmts[$key - 1]); + $stmtsAware->stmts[$key] = $newExpression; - $node->stmts = array_values($node->stmts); + $stmtsAware->stmts = array_values($stmtsAware->stmts); - return $node; + return $stmtsAware; } return null; } - private function refactorEarlyReturnPattern(StmtsAwareInterface $node): ?Node + private function refactorEarlyReturnPattern(StmtsAwareInterface $stmtsAware): ?Node { - foreach ($node->stmts as $key => $stmt) { + foreach ($stmtsAware->stmts as $key => $stmt) { if (! $stmt instanceof Foreach_) { continue; } $foreach = $stmt; - $nextStmt = $node->stmts[$key + 1] ?? null; + $nextStmt = $stmtsAware->stmts[$key + 1] ?? null; if (! $nextStmt instanceof Return_) { continue; @@ -232,11 +232,11 @@ private function refactorEarlyReturnPattern(StmtsAwareInterface $node): ?Node $funcCall = $this->nodeFactory->createFuncCall('array_any', [$foreach->expr, $arrowFunction]); - $node->stmts[$key] = new Return_($funcCall); - unset($node->stmts[$key + 1]); - $node->stmts = array_values($node->stmts); + $stmtsAware->stmts[$key] = new Return_($funcCall); + unset($stmtsAware->stmts[$key + 1]); + $stmtsAware->stmts = array_values($stmtsAware->stmts); - return $node; + return $stmtsAware; } return null; diff --git a/rules/Php85/Rector/ClassMethod/NullDebugInfoReturnRector.php b/rules/Php85/Rector/ClassMethod/NullDebugInfoReturnRector.php index 65f5dbf88ba..e5ed9d260fa 100644 --- a/rules/Php85/Rector/ClassMethod/NullDebugInfoReturnRector.php +++ b/rules/Php85/Rector/ClassMethod/NullDebugInfoReturnRector.php @@ -75,7 +75,7 @@ public function refactor(Node $node): ?Node } $hasChanged = \false; - $this->traverseNodesWithCallable((array) $node->stmts, function (Node $node) use (&$hasChanged) { + $this->traverseNodesWithCallable((array) $node->stmts, function (Node $node) use (&$hasChanged): int|Return_|null { if ($node instanceof Class_ || $node instanceof Function_ || $node instanceof Closure) { return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; }