-
-
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][Php56] Handle infinite loop on RemoveUnusedVariableAssignR…
…ector+AddDefaultValueForUndefinedVariableRector take 2 (#3941) * [DeadCode][Php56] Handle infinite loop on RemoveUnusedVariableAssignRector+AddDefaultValueForUndefinedVariableRector take 2 * Fixed 🎉 * Fix phpstan
- Loading branch information
1 parent
e04e51c
commit a354eda
Showing
2 changed files
with
64 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
tests/Issues/RemoveUnusedVariableDefault/Fixture/re_used_assign.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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\RemoveUnusedVariableDefault\Fixture; | ||
|
||
final class ReUsedAssign | ||
{ | ||
public function testCastAsJSONErrorDepth() | ||
{ | ||
// Create array with depth 513 to get depth error | ||
$array = []; | ||
$value = 'test value'; | ||
$keys = rtrim(str_repeat('test.', 513), '.'); | ||
$keys = explode('.', $keys); | ||
$current = $array; | ||
|
||
foreach ($keys as $key) { | ||
$current = $current[$key]; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\RemoveUnusedVariableDefault\Fixture; | ||
|
||
final class ReUsedAssign | ||
{ | ||
public function testCastAsJSONErrorDepth() | ||
{ | ||
// Create array with depth 513 to get depth error | ||
$array = []; | ||
$keys = rtrim(str_repeat('test.', 513), '.'); | ||
$keys = explode('.', $keys); | ||
$current = $array; | ||
|
||
foreach ($keys as $key) { | ||
$current = $current[$key]; | ||
} | ||
} | ||
} | ||
|
||
?> |