-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Skip non-array type on SimplifyForeachToArrayFilterRect…
…or (#3738) * [CodeQuality] Skip non-array type on SimplifyForeachToArrayFilterRector * Fixed 🎉 * eol * pure check ArrayType * update to use isArray()->yes() usage
- Loading branch information
1 parent
07e9ccf
commit a3ea0cf
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ty/Rector/Foreach_/SimplifyForeachToArrayFilterRector/Fixture/skip_non_array_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,25 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector\Fixture; | ||
|
||
final class SkipNonArrayType | ||
{ | ||
public function __construct( | ||
public int $a, | ||
public ?int $b | ||
) { | ||
} | ||
|
||
public function run() | ||
{ | ||
$a = new SkipNonArrayType(3, null); | ||
|
||
$arr = []; | ||
foreach($a as $k => $v) { | ||
if($v !== null) { | ||
$arr[$k] = $v; | ||
} | ||
} | ||
echo json_encode($arr); | ||
} | ||
} |
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