From 527552a4cac584136847f23a87ee7b6ab2a54694 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 21 Oct 2026 22:58:20 +0200 Subject: [PATCH] [DeadCode] Compare switch case stmts node-by-node in RemoveDuplicatedCaseInSwitchRector Compare the two case stmt lists by length then element-wise via areNodesEqual, instead of passing the arrays to the array overload. Avoids printing the whole statement lists and no longer depends on that overload. --- .../Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php index ad238a4b246..43af54d2a4b 100644 --- a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php +++ b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php @@ -177,10 +177,16 @@ private function areSwitchStmtsEqualsAndWithBreak(Case_ $currentCase, Case_ $nex return $this->areSwitchStmtsEqualsConsideringComments($currentCase, $nextCase); } - if (! $this->nodeComparator->areNodesEqual($currentCase->stmts, $nextCase->stmts)) { + if (count($currentCase->stmts) !== count($nextCase->stmts)) { return false; } + foreach ($currentCase->stmts as $key => $currentStmt) { + if (! $this->nodeComparator->areNodesEqual($currentStmt, $nextCase->stmts[$key])) { + return false; + } + } + return array_any( $currentCase->stmts, fn (Stmt $stmt): bool => $stmt instanceof Break_ || $stmt instanceof Return_