From ebc06ca0c207ea729cd4b3cfb77bfbe45de0554b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 17 Nov 2024 20:46:57 +0700 Subject: [PATCH] Fix orig node set on ChangeNestedForeachIfsToEarlyContinueRector --- .../Fixture/comment_inside_if_statement.php.inc | 1 - .../Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rules-tests/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector/Fixture/comment_inside_if_statement.php.inc b/rules-tests/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector/Fixture/comment_inside_if_statement.php.inc index ec3cc097ae9..b0dacbd139d 100644 --- a/rules-tests/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector/Fixture/comment_inside_if_statement.php.inc +++ b/rules-tests/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector/Fixture/comment_inside_if_statement.php.inc @@ -35,7 +35,6 @@ class CommentInsideIfStatement if ($value !== 5) { continue; } - // why am I doing this? if ($value !== 10) { continue; } diff --git a/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php b/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php index a29b21826c6..9c91e8558fb 100644 --- a/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php +++ b/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php @@ -96,6 +96,10 @@ public function refactor(Node $node): ?Node return null; } + foreach ($nestedIfsWithOnlyNonReturn as $nestedIf) { + $nestedIf->cond->setAttribute(AttributeKey::ORIGINAL_NODE, null); + } + return $this->processNestedIfsWithNonBreaking($node, $nestedIfsWithOnlyNonReturn); }