-
-
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 deep append in if foreach before on ForeachItemsAs…
…signToEmptyArrayToAssignRector (#4053)
- Loading branch information
1 parent
069e53a
commit c9fc74b
Showing
2 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ch_/ForeachItemsAssignToEmptyArrayToAssignRector/Fixture/skip_deep_append_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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector\Fixture; | ||
|
||
class SkipDeepAppendForeach | ||
{ | ||
public function run(array $items) | ||
{ | ||
$items2 = []; | ||
|
||
if (rand(0, 1)) { | ||
foreach (['foo', 'bar'] as $item) { | ||
$items2[] = $item; | ||
} | ||
} | ||
|
||
foreach ($items as $item) { | ||
$items2[] = $item; | ||
} | ||
} | ||
} | ||
|
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