-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EarlyReturn] Do not move up variable up next foreach on ChangeAndIfT…
…oEarlyReturnRector (#852) * [EarlyReturn] Do not move up variable up next foreach * update fixture * Fixed 🎉 * cs
- Loading branch information
1 parent
5b17710
commit 70e4b3c
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...Rector/If_/ChangeAndIfToEarlyReturnRector/Fixture/do_not_move_variable_up_foreach.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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector\Fixture; | ||
|
||
class DoNotMoveVariableUpForeach | ||
{ | ||
public function run(array $data, $a, $b) | ||
{ | ||
foreach ($data as $value) { | ||
if ($a && $b) { | ||
unset($value); | ||
} | ||
} | ||
|
||
$targets = []; | ||
return $targets; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector\Fixture; | ||
|
||
class DoNotMoveVariableUpForeach | ||
{ | ||
public function run(array $data, $a, $b) | ||
{ | ||
foreach ($data as $value) { | ||
if (!$a) { | ||
continue; | ||
} | ||
if (!$b) { | ||
continue; | ||
} | ||
unset($value); | ||
} | ||
|
||
$targets = []; | ||
return $targets; | ||
} | ||
} | ||
|
||
?> |
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