diff --git a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php index a03d3995f1a..96858b1bf87 100644 --- a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php +++ b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php @@ -77,7 +77,6 @@ CODE_SAMPLE $this->hasChanged = \false; $insertByKeys = $this->resolveInsertedByKeys($node); $this->insertCaseByKeys($node, $insertByKeys); - $this->cleanUpEqualCaseStmts($node); if (!$this->hasChanged) { return null; } @@ -94,7 +93,6 @@ CODE_SAMPLE if ($case->stmts === []) { continue; } - $nextKey = $key + 1; for ($jumpToKey = $key + 1; $jumpToKey < $totalKeys; ++$jumpToKey) { if (!isset($switch->cases[$jumpToKey])) { continue; @@ -102,9 +100,6 @@ CODE_SAMPLE if (!$this->areSwitchStmtsEqualsAndWithBreak($case, $switch->cases[$jumpToKey])) { continue; } - if ($nextKey === $jumpToKey) { - continue 2; - } $nextCase = $switch->cases[$jumpToKey]; unset($switch->cases[$jumpToKey]); $insertByKeys[$key][] = $nextCase; @@ -119,21 +114,11 @@ CODE_SAMPLE private function insertCaseByKeys(Switch_ $switch, array $insertByKeys) : void { foreach ($insertByKeys as $key => $insertByKey) { - $switch->cases[$key]->stmts = []; $nextKey = $key + 1; \array_splice($switch->cases, $nextKey, 0, $insertByKey); - } - } - private function cleanUpEqualCaseStmts(Switch_ $switch) : void - { - /** @var Case_|null $previousCase */ - $previousCase = null; - foreach ($switch->cases as $case) { - if ($previousCase instanceof Case_ && $this->areSwitchStmtsEqualsAndWithBreak($case, $previousCase)) { - $previousCase->stmts = []; - $this->hasChanged = \true; + for ($jumpToKey = $key; $jumpToKey < $key + \count($insertByKey); ++$jumpToKey) { + $switch->cases[$jumpToKey]->stmts = []; } - $previousCase = $case; } } private function areSwitchStmtsEqualsAndWithBreak(Case_ $currentCase, Case_ $nextCase) : bool diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index c5e1bb42f1f..6d4b88abe83 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '3f2fb29fe87904d779fb2f8d3e59492aaa9249f4'; + public const PACKAGE_VERSION = 'c61d8ea90edb04550b6a43f40bd6c6105a997189'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-11-10 05:04:21'; + public const RELEASE_DATE = '2023-11-10 05:53:14'; /** * @var int */