-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Skip remove variable on switch use return after break on R…
…emoveUnusedVariableAssignRector (#2145) * [DeadCode] Skip remove on switch use return after break on RemoveUnusedVariableAssignRector * Fixed 🎉 * check against RemoveUnreachableStatementRector which remove the return after break * rename fixture * rename fixture * eol
- Loading branch information
1 parent
55807fa
commit dc7a9a8
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...iableAssignRector/Fixture/skip_remove_variable_on_next_return_after_break_in_case.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,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture; | ||
|
||
final class SkipRemoveVariableOnNextReturnAfterBreakInCase | ||
{ | ||
public function run($a) | ||
{ | ||
switch ($a) | ||
{ | ||
case 'A': | ||
$x = 'a'; | ||
break; | ||
return; | ||
} | ||
|
||
echo $x; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...de/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/switch_return_after_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,42 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector\Fixture; | ||
|
||
final class SwitchReturnAfterBreak | ||
{ | ||
public function run($a) | ||
{ | ||
switch ($a) | ||
{ | ||
case 'A': | ||
$x = 'a'; | ||
break; | ||
return; | ||
} | ||
|
||
echo $x; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector\Fixture; | ||
|
||
final class SwitchReturnAfterBreak | ||
{ | ||
public function run($a) | ||
{ | ||
switch ($a) | ||
{ | ||
case 'A': | ||
$x = 'a'; | ||
break; | ||
} | ||
|
||
echo $x; | ||
} | ||
} | ||
|
||
?> |
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