Skip to content

Commit

Permalink
Add support for arrow functions in DowngradeUnionTypeDeclarationRector (
Browse files Browse the repository at this point in the history
  • Loading branch information
villfa committed Nov 24, 2021
1 parent 11ca58a commit 3d49ef2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector\Fixture;

$fn = fn (stdClass|null $obj): stdClass|null => $obj;

?>
-----
<?php

namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector\Fixture;

$fn = fn ($obj) => $obj;

?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\DowngradePhp80\Rector\FunctionLike;

use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
Expand All @@ -31,7 +32,7 @@ public function __construct(
*/
public function getNodeTypes(): array
{
return [Function_::class, ClassMethod::class, Closure::class];
return [Function_::class, ClassMethod::class, Closure::class, ArrowFunction::class];
}

public function getRuleDefinition(): RuleDefinition
Expand Down Expand Up @@ -69,7 +70,7 @@ public function echoInput($input)
}

/**
* @param ClassMethod|Closure|Function_ $node
* @param ClassMethod|Closure|Function_|ArrowFunction $node
*/
public function refactor(Node $node): ?Node
{
Expand Down

0 comments on commit 3d49ef2

Please sign in to comment.