diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/Fixture/first_class_callable.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/Fixture/first_class_callable.php.inc new file mode 100644 index 00000000000..19e228d8c0a --- /dev/null +++ b/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/Fixture/first_class_callable.php.inc @@ -0,0 +1,47 @@ +redirector = new Redirector(); + } + + public function run() + { + $args = \func_get_args(); + call_user_func_array($this->redirector->redirect(...), $args); + } +} + +?> +----- +redirector = new Redirector(); + } + + public function run() + { + $args = \func_get_args(); + $this->redirector->redirect(...$args); + } +} + +?> diff --git a/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/config/configured_rule.php b/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/config/configured_rule.php index 8a8e880d5d6..3e6371d19e6 100644 --- a/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/config/configured_rule.php +++ b/rules-tests/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector/config/configured_rule.php @@ -7,7 +7,7 @@ use Rector\ValueObject\PhpVersion; return static function (RectorConfig $rectorConfig): void { - $rectorConfig->phpVersion(PhpVersion::PHP_74); + $rectorConfig->phpVersion(PhpVersion::PHP_80); $rectorConfig->rule(CallUserFuncArrayToVariadicRector::class); }; diff --git a/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php b/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php index b967fbb2bcc..74774df94aa 100644 --- a/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php @@ -93,6 +93,12 @@ public function refactor(Node $node): ?Node return $this->createMethodCall($firstArgValue, $secondArgValue); } + if ($firstArgValue instanceof MethodCall && $firstArgValue->isFirstClassCallable()) { + $firstArgValue->args = [$this->createUnpackedArg($secondArgValue)]; + + return $firstArgValue; + } + return null; } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector.php index 8bb419c6902..34b4c225ee9 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector.php @@ -110,7 +110,9 @@ public function refactor(Node $node): ?Node } } - if ($this->isName($classMethod, MethodName::__GET) && $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::MIXED_TYPE) && ! $classMethod->returnType instanceof Node) { + if ($this->isName($classMethod, MethodName::__GET) && $this->phpVersionProvider->isAtLeastPhpVersion( + PhpVersionFeature::MIXED_TYPE + ) && ! $classMethod->returnType instanceof Node) { $classMethod->returnType = new Identifier('mixed'); $hasChanged = true; }