Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PHP 7.2] Add error suppres support to each() rule (#5844)
- Loading branch information
1 parent
d5069f0
commit 8281a06
Showing
6 changed files
with
113 additions
and
51 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
rules-tests/Php72/Rector/While_/WhileEachToForeachRector/Fixture/include_supress.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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php72\Rector\While_\WhileEachToForeachRector\Fixture; | ||
|
||
final class IncludeSupress | ||
{ | ||
public function run(array $items) | ||
{ | ||
while (list(, $item) = @each($items)) { | ||
// some code | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php72\Rector\While_\WhileEachToForeachRector\Fixture; | ||
|
||
final class IncludeSupress | ||
{ | ||
public function run(array $items) | ||
{ | ||
foreach ($items as $item) { | ||
// some code | ||
} | ||
} | ||
} | ||
|
||
?> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Php72\ValueObject; | ||
|
||
use PhpParser\Node\Expr\FuncCall; | ||
use PhpParser\Node\Expr\List_; | ||
|
||
final readonly class ListAndEach | ||
{ | ||
public function __construct( | ||
private List_ $list, | ||
private FuncCall $eachFuncCall, | ||
) { | ||
} | ||
|
||
public function getList(): List_ | ||
{ | ||
return $this->list; | ||
} | ||
|
||
public function getEachFuncCall(): FuncCall | ||
{ | ||
return $this->eachFuncCall; | ||
} | ||
} |
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