-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Skip nullable array on not empty on RemoveUnusedNonEmptyAr…
…rayBeforeForeachRector (#2935) * [DeadCode] Skip nullable array on not empty on RemoveUnusedNonEmptyArrayBeforeForeachRector * Fixed 🎉 * clean up * clean up * eol
- Loading branch information
1 parent
5f05178
commit 4923a14
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...veUnusedNonEmptyArrayBeforeForeachRector/Fixture/skip_nullable_array_on_not_empty.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,21 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector\Fixture; | ||
|
||
class SkipNullableArrayOnNotEmpty | ||
{ | ||
public function getPrice() | ||
{ | ||
$tierPrices = random_int(0, 1) ? [] : null; | ||
|
||
if (! empty($tierPrices)) { | ||
foreach ($tierPrices as $tierPrice) { | ||
if ($tierPrice >= 0) { | ||
return $tierPrice; | ||
} | ||
} | ||
} | ||
|
||
return 0.0; | ||
} | ||
} |
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
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