-
-
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.
[Php72] Handle crash on trailing comma last on WhileEachToForeachRect…
…or (#3186)
- Loading branch information
1 parent
e479114
commit 802d98e
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
rules-tests/Php72/Rector/While_/WhileEachToForeachRector/Fixture/trailing_comma_last.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,34 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php72\Rector\While_\WhileEachToForeachRector\Fixture; | ||
|
||
// ref https://3v4l.org/mTeIL#v7.1.31 vs https://3v4l.org/UJH9S | ||
final class TrailingCommaLast | ||
{ | ||
public function run() | ||
{ | ||
while(list($code_name,) = each($poster_xd)) | ||
{ | ||
$poster_xd[$code_name] = preg_replace($orig_word, $replacement_word, $poster_xd[$code_name]); | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php72\Rector\While_\WhileEachToForeachRector\Fixture; | ||
|
||
// ref https://3v4l.org/mTeIL#v7.1.31 vs https://3v4l.org/UJH9S | ||
final class TrailingCommaLast | ||
{ | ||
public function run() | ||
{ | ||
foreach (array_keys($poster_xd) as $code_name) { | ||
$poster_xd[$code_name] = preg_replace($orig_word, $replacement_word, $poster_xd[$code_name]); | ||
} | ||
} | ||
} | ||
|
||
?> |
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