Updated Rector to commit bee1dae395490dd91a86230e1886b514288dfa62

bee1dae395 [DeadCode] Handle different indirect duplicated on RemoveDuplicatedCaseInSwitchRector (#5236)
This commit is contained in:
Tomas Votruba 2023-11-10 06:59:59 +00:00
parent 373eece1e0
commit c51a745c50
2 changed files with 13 additions and 6 deletions

View File

@ -89,11 +89,12 @@ CODE_SAMPLE
{
$totalKeys = \count($switch->cases);
$insertByKeys = [];
$appendKey = 0;
foreach ($switch->cases as $key => $case) {
if ($case->stmts === []) {
continue;
}
for ($jumpToKey = $key + 1; $jumpToKey < $totalKeys; ++$jumpToKey) {
for ($jumpToKey = $key + 2; $jumpToKey < $totalKeys; ++$jumpToKey) {
if (!isset($switch->cases[$jumpToKey])) {
continue;
}
@ -102,9 +103,10 @@ CODE_SAMPLE
}
$nextCase = $switch->cases[$jumpToKey];
unset($switch->cases[$jumpToKey]);
$insertByKeys[$key][] = $nextCase;
$insertByKeys[$key + $appendKey][] = $nextCase;
$this->hasChanged = \true;
}
$appendKey = isset($insertByKeys[$key]) ? \count($insertByKeys[$key]) : 0;
}
return $insertByKeys;
}
@ -116,9 +118,14 @@ CODE_SAMPLE
foreach ($insertByKeys as $key => $insertByKey) {
$nextKey = $key + 1;
\array_splice($switch->cases, $nextKey, 0, $insertByKey);
for ($jumpToKey = $key; $jumpToKey < $key + \count($insertByKey); ++$jumpToKey) {
$switch->cases[$jumpToKey]->stmts = [];
}
/** @var Case_|null $previousCase */
$previousCase = null;
foreach ($switch->cases as $case) {
if ($previousCase instanceof Case_ && $this->areSwitchStmtsEqualsAndWithBreak($case, $previousCase)) {
$previousCase->stmts = [];
}
$previousCase = $case;
}
}
private function areSwitchStmtsEqualsAndWithBreak(Case_ $currentCase, Case_ $nextCase) : bool

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'c61d8ea90edb04550b6a43f40bd6c6105a997189';
public const PACKAGE_VERSION = 'bee1dae395490dd91a86230e1886b514288dfa62';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-11-10 05:53:14';
public const RELEASE_DATE = '2023-11-10 13:57:49';
/**
* @var int
*/