mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 16:32:27 +02:00
[CodingStyle] remove extra break from BinarySwitchToIfElseRector
This commit is contained in:
parent
f1decfd723
commit
5a0258cc55
@ -95,7 +95,7 @@ CODE_SAMPLE
|
||||
$ifNode->elseifs[] = new ElseIf_($equalNode, $this->removeBreakNodes($secondCase->stmts));
|
||||
} else {
|
||||
// defaults
|
||||
$ifNode->else = new Else_($secondCase->stmts);
|
||||
$ifNode->else = new Else_($this->removeBreakNodes($secondCase->stmts));
|
||||
}
|
||||
|
||||
return $ifNode;
|
||||
|
@ -13,6 +13,7 @@ final class BinarySwitchToIfElseRectorTest extends AbstractRectorTestCase
|
||||
__DIR__ . '/Fixture/fixture.php.inc',
|
||||
__DIR__ . '/Fixture/in_class.php.inc',
|
||||
__DIR__ . '/Fixture/if_or.php.inc',
|
||||
__DIR__ . '/Fixture/extra_break.php.inc',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\CodingStyle\Tests\Rector\Switch_\BinarySwitchToIfElseRector;
|
||||
|
||||
final class ExtraBreak
|
||||
{
|
||||
public function run($meal)
|
||||
{
|
||||
switch ($meal) {
|
||||
case 'morning-food':
|
||||
$food = 'small chicken';
|
||||
break;
|
||||
default:
|
||||
$food = 'chicken';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\CodingStyle\Tests\Rector\Switch_\BinarySwitchToIfElseRector;
|
||||
|
||||
final class ExtraBreak
|
||||
{
|
||||
public function run($meal)
|
||||
{
|
||||
if ($meal == 'morning-food') {
|
||||
$food = 'small chicken';
|
||||
} else {
|
||||
$food = 'chicken';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user