-
-
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.
[EarlyReturn] Handle crash on assign in if else before on RemoveAlway…
…sElseRector (#2822) Co-authored-by: Shin <2082119+shinsenter@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
837c226
commit 54feb0d
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...ts/EarlyReturn/Rector/If_/RemoveAlwaysElseRector/Fixture/assign_in_if_else_before.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,55 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\EarlyReturn\Rector\If_\RemoveAlwaysElseRector\Fixture; | ||
|
||
function assignInIfElseBefore($can_order_products, $offset, $limit) | ||
{ | ||
if (!empty($can_order_products)) { | ||
if (!empty($limit)) { | ||
if (!empty($offset)) { | ||
$can_order_products = array_slice($can_order_products, $offset, $limit); | ||
} else { | ||
$can_order_products = array_slice($can_order_products, 0, $limit); | ||
} | ||
|
||
if (!empty($can_order_products)) { | ||
return $can_order_products; | ||
} else { | ||
return false; | ||
} | ||
} else { | ||
return $can_order_products; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\EarlyReturn\Rector\If_\RemoveAlwaysElseRector\Fixture; | ||
|
||
function assignInIfElseBefore($can_order_products, $offset, $limit) | ||
{ | ||
if (!empty($can_order_products)) { | ||
if (!empty($limit)) { | ||
if (!empty($offset)) { | ||
$can_order_products = array_slice($can_order_products, $offset, $limit); | ||
} else { | ||
$can_order_products = array_slice($can_order_products, 0, $limit); | ||
} | ||
|
||
if (!empty($can_order_products)) { | ||
return $can_order_products; | ||
} | ||
return false; | ||
} | ||
return $can_order_products; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
?> |
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