Skip to content

Commit 1aff76b

Browse files
authored
[Php80] Skip case after default empty on ChangeSwitchToMatchRector (#6805)
* [Php80] Skip case after default empty on ChangeSwitchToMatchRector * fix
1 parent 18f9216 commit 1aff76b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\Switch_\ChangeSwitchToMatchRector\Fixture;
4+
5+
class SkipCaseAfterDefaultEmpty
6+
{
7+
public function run(string $type)
8+
{
9+
switch ($type) {
10+
case 'day':
11+
$format = '%Y-%m-%d';
12+
break;
13+
default:
14+
case 'hour':
15+
$format = '%Y-%m-%d %H';
16+
break;
17+
}
18+
19+
return $format;
20+
}
21+
}

rules/Php80/NodeResolver/SwitchExprsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function resolve(Switch_ $switch): array
3939
}
4040

4141
if (! $case->cond instanceof Expr) {
42-
continue;
42+
return [];
4343
}
4444

4545
$collectionEmptyCasesCond[$key] = $case->cond;

0 commit comments

Comments
 (0)