-
-
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.
[CodeQuality] Skip not ArrayType on ForeachItemsAssignToEmptyArrayToA…
…ssignRector (#2752) Co-authored-by: Gocha Ossinkine <ossinkine@ya.ru>
- Loading branch information
1 parent
77a0b34
commit c0070b1
Showing
4 changed files
with
37 additions
and
16 deletions.
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
...tor/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector/Fixture/skip_mixed_type.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,14 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector\Fixture; | ||
|
||
class SkipMixedType | ||
{ | ||
public function run($items) | ||
{ | ||
$items2 = []; | ||
foreach ($items as $item) { | ||
$items2[] = $item; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...or/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector/Fixture/skip_traversable.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\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector\Fixture; | ||
|
||
class SkipTraversable | ||
{ | ||
public function run() | ||
{ | ||
$items = []; | ||
foreach ($this->getTraversable() as $item) { | ||
$items[] = $item; | ||
} | ||
} | ||
|
||
private function getTraversable(): iterable | ||
{ | ||
yield 123; | ||
} | ||
} |
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