-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Skip with break on SwitchTrueToIfRector (#3634)
* Add failing test fixture for SwitchTrueToIfRector # Failing Test for SwitchTrueToIfRector Based on https://getrector.com/demo/4ea2ecee-99f7-474e-b74e-a2db47a1e1eb * fix * Final touch: use end($case->stmts) to be Return_ stmt check --------- Co-authored-by: pgr-dS <110042614+pgr-dS@users.noreply.github.com>
- Loading branch information
1 parent
f453969
commit f08216f
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
rules-tests/CodeQuality/Rector/Switch_/SwitchTrueToIfRector/Fixture/skip_break.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Switch_\SwitchTrueToIfRector\Fixture; | ||
|
||
final class SkipBreak | ||
{ | ||
public function run(int $int): string | ||
{ | ||
$str = 'error'; | ||
switch (true) { | ||
case $int === 0: | ||
$str = 'zero'; | ||
break; | ||
case $int%2 === 1: | ||
$str = 'odd'; | ||
break; | ||
case $int%2 === 0: | ||
$str = 'even'; | ||
break; | ||
} | ||
|
||
return $str; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters