-
-
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.
[Php56][Php70][Php74] Handle infinite loop on AddDefaultValueForUndef…
…inedVariableRector+IfToSpaceshipRector+ClosureToArrowFunctionRector (#3701) * [Php56][Php70][Php74] Handle infinite loop on AddDefaultValueForUndefinedVariableRector+IfToSpaceshipRector+ClosureToArrowFunctionRector * fixtue * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
b3e2696
commit 31f64cc
Showing
5 changed files
with
83 additions
and
3 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
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
28 changes: 28 additions & 0 deletions
28
tests/Issues/DefaultValueSpaceShipClosure/DefaultValueSpaceShipClosureTest.php
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\DefaultValueSpaceShipClosure; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class DefaultValueSpaceShipClosureTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/Issues/DefaultValueSpaceShipClosure/Fixture/fixture.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,33 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\DefaultValueSpaceShipClosure\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
uasort([], function ($a, $b) { | ||
if ($a == $b) { | ||
return 0; | ||
} | ||
|
||
return ($a > $b) ? -1 : 1; | ||
}); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\DefaultValueSpaceShipClosure\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
uasort([], fn($a, $b) => $b <=> $a); | ||
} | ||
} | ||
|
||
?> |
18 changes: 18 additions & 0 deletions
18
tests/Issues/DefaultValueSpaceShipClosure/config/configured_rule.php
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; | ||
use Rector\Php70\Rector\If_\IfToSpaceshipRector; | ||
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rules( | ||
[ | ||
AddDefaultValueForUndefinedVariableRector::class, | ||
IfToSpaceshipRector::class, | ||
ClosureToArrowFunctionRector::class, | ||
] | ||
); | ||
}; |