diff --git a/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php b/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php index dd05e05a3c..83d9bce370 100644 --- a/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php +++ b/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php @@ -215,7 +215,7 @@ private function matchConstructorParams(ClassMethod $classMethod): array $totalParams = count($classMethod->params); - foreach ($params as $key => $param) { + foreach (array_keys($params) as $key) { for ($iteration = $key + 1; $iteration < $totalParams; ++$iteration) { if (isset($classMethod->params[$iteration]) && ! $classMethod->params[$iteration]->default instanceof Expr) { return [];