Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector\Fixture;

use Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector\Source\Redirector;

final class FirstClassCallable
{
private $redirector;

public function __construct()
{
$this->redirector = new Redirector();
}

public function run()
{
$args = \func_get_args();
call_user_func_array($this->redirector->redirect(...), $args);
}
}

?>
-----
<?php

namespace Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector\Fixture;

use Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector\Source\Redirector;

final class FirstClassCallable
{
private $redirector;

public function __construct()
{
$this->redirector = new Redirector();
}

public function run()
{
$args = \func_get_args();
$this->redirector->redirect(...$args);
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading