mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 19:53:14 +01:00
Merge pull request #2896 from rectorphp/static-reatin
keep array function static
This commit is contained in:
commit
d4d0285a94
@ -17,6 +17,7 @@ use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
|
||||
/**
|
||||
* @see https://wiki.php.net/rfc/arrow_functions_v2
|
||||
*
|
||||
* @see \Rector\Php74\Tests\Rector\Closure\ClosureToArrowFunctionRector\ClosureToArrowFunctionRectorTest
|
||||
*/
|
||||
final class ClosureToArrowFunctionRector extends AbstractRector
|
||||
@ -92,6 +93,10 @@ PHP
|
||||
|
||||
$arrowFunction->expr = $return->expr;
|
||||
|
||||
if ($node->static === true) {
|
||||
$arrowFunction->static = true;
|
||||
}
|
||||
|
||||
return $arrowFunction;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Php74\Tests\Rector\Closure\ClosureToArrowFunctionRector\Fixture;
|
||||
|
||||
class RetainStatic
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$bars = array_map(static function (int $value): int {
|
||||
return $value * 2;
|
||||
}, [1, 2, 3]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php74\Tests\Rector\Closure\ClosureToArrowFunctionRector\Fixture;
|
||||
|
||||
class RetainStatic
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$bars = array_map(static fn(int $value): int => $value * 2, [1, 2, 3]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user