From 76fe5e3f965bc540cb6925a1cecbc82e8b08dccb Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 30 Oct 2026 20:00:54 +0700 Subject: [PATCH] [DeadCode] Skip with HTML on RemoveAlwaysTrueIfConditionRector --- .../Fixture/skip_with_html.php.inc | 9 +++++++++ .../If_/RemoveAlwaysTrueIfConditionRector.php | 14 +++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 rules-tests/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector/Fixture/skip_with_html.php.inc diff --git a/rules-tests/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector/Fixture/skip_with_html.php.inc b/rules-tests/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector/Fixture/skip_with_html.php.inc new file mode 100644 index 00000000000..685f9ffd037 --- /dev/null +++ b/rules-tests/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector/Fixture/skip_with_html.php.inc @@ -0,0 +1,9 @@ + + Always visible +cond instanceof BooleanAnd) { - return $this->refactorIfWithBooleanAnd($node); - } - if ($node->else instanceof Else_) { return null; } - // just one if + // not just one if if ($node->elseifs !== []) { return null; } + if ($this->getFile()->containsHTML()) { + return null; + } + + if ($node->cond instanceof BooleanAnd) { + return $this->refactorIfWithBooleanAnd($node); + } + if ($this->shouldSkipExpr($node->cond)) { return null; }