-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Handle CallableThisArrayToAnonymousFunctionRector on st…
…atic call (#382) * Add failing test fixture for CallableThisArrayToAnonymousFunctionRector # Failing Test for CallableThisArrayToAnonymousFunctionRector Based on https://getrector.org/demo/1ebdd568-53a1-6744-871e-eb16ad5fe7b4 * Closes #381 * phpstan Co-authored-by: Zing <zingimmick@outlook.com>
- Loading branch information
1 parent
ff1ad31
commit c0d6760
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...lity/Rector/Array_/CallableThisArrayToAnonymousFunctionRector/Fixture/static_call.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,43 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector\Fixture; | ||
|
||
final class StaticCall | ||
{ | ||
public function run(array $values) | ||
{ | ||
usort($values, [StaticCall::class, 'compareSize']); | ||
|
||
return $values; | ||
} | ||
|
||
private static function compareSize(int $first, $second): bool | ||
{ | ||
return $first <=> $second; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector\Fixture; | ||
|
||
final class StaticCall | ||
{ | ||
public function run(array $values) | ||
{ | ||
usort($values, function (int $first, $second) : bool { | ||
return StaticCall::compareSize($first, $second); | ||
}); | ||
|
||
return $values; | ||
} | ||
|
||
private static function compareSize(int $first, $second): bool | ||
{ | ||
return $first <=> $second; | ||
} | ||
} | ||
|
||
?> |
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