From c14f8d45175bd4c10fef503e350d677c4a73ce29 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 8 Mar 2024 13:31:37 +0700 Subject: [PATCH] [Php72][TypeDeclaration] Rollback tweak infinite loop handling on DeclareStrictTypesRector (#5700) --- .../Rector/StmtsAwareInterface/DeclareStrictTypesRector.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php b/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php index 422d33ef98a..2402114ea50 100644 --- a/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php +++ b/rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php @@ -64,13 +64,11 @@ public function beforeTraverse(array $nodes): ?array return null; } - // use 0 index to avoid infinite loop - $rootStmt = $newStmts[0] ?? null; + $rootStmt = current($newStmts); $stmt = $rootStmt; if ($rootStmt instanceof FileWithoutNamespace) { - // use 0 index to avoid infinite loop - $currentStmt = $rootStmt->stmts[0] ?? null; + $currentStmt = current($rootStmt->stmts); if (! $currentStmt instanceof Stmt) { return null;