-
-
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.
[DeadCode] Fix known array type in empty if foreach (#2432)
- Loading branch information
1 parent
83f7e9f
commit 70261b7
Showing
3 changed files
with
55 additions
and
0 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
45 changes: 45 additions & 0 deletions
45
.../Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector/Fixture/property_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\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector\Fixture; | ||
|
||
final class PropertyForeach | ||
{ | ||
private $items = []; | ||
|
||
public function __construct(array $items) | ||
{ | ||
$this->items = $items; | ||
} | ||
|
||
public function run() | ||
{ | ||
if ($this->items) { | ||
foreach ($this->items as $item) { | ||
} | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector\Fixture; | ||
|
||
final class PropertyForeach | ||
{ | ||
private $items = []; | ||
|
||
public function __construct(array $items) | ||
{ | ||
$this->items = $items; | ||
} | ||
|
||
public function run() | ||
{ | ||
foreach ($this->items as $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