From 3d49ef2015f61cf2fa6ec66d8a5a76a49de5828e Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Wed, 24 Nov 2021 11:06:25 +0100 Subject: [PATCH] Add support for arrow functions in DowngradeUnionTypeDeclarationRector (#1296) --- .../config/configured_rule.php | 11 ----------- .../Fixture/array_function.php.inc | 15 +++++++++++++++ .../DowngradeUnionTypeDeclarationRector.php | 5 +++-- 3 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeStaticTypeDeclarationRector/config/configured_rule.php create mode 100644 rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector/Fixture/array_function.php.inc diff --git a/rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeStaticTypeDeclarationRector/config/configured_rule.php b/rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeStaticTypeDeclarationRector/config/configured_rule.php deleted file mode 100644 index fb6681d737a..00000000000 --- a/rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeStaticTypeDeclarationRector/config/configured_rule.php +++ /dev/null @@ -1,11 +0,0 @@ -services(); - $services->set(DowngradeStaticTypeDeclarationRector::class); -}; diff --git a/rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector/Fixture/array_function.php.inc b/rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector/Fixture/array_function.php.inc new file mode 100644 index 00000000000..190651b4930 --- /dev/null +++ b/rules-tests/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector/Fixture/array_function.php.inc @@ -0,0 +1,15 @@ + $obj; + +?> +----- + $obj; + +?> diff --git a/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php b/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php index a2eb24dec7d..80fe2d822ca 100644 --- a/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php +++ b/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php @@ -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_; @@ -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 @@ -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 {