Skip to content

Commit

Permalink
Rectify (#6408)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Nov 4, 2024
1 parent f7ea3db commit 1afc647
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
namespace Rector\Php83\Rector\FuncCall;

use PhpParser\Node;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
use PhpParser\Node\VarLikeIdentifier;
use Rector\Rector\AbstractRector;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
Expand All @@ -18,7 +22,7 @@ final class RemoveGetClassGetParentClassNoArgsRector extends AbstractRector impl
{
public function getRuleDefinition(): RuleDefinition
{
$r = new RuleDefinition(
return new RuleDefinition(
'Replace calls to get_class() and get_parent_class() without arguments with self::class and parent::class.',
[
new CodeSample(
Expand All @@ -40,20 +44,18 @@ public function whoAreYou() {
),
]
);

return $r;
}

/**
* @return array<class-string<Node>>
*/
public function getNodeTypes(): array
{
return [Node\Expr\FuncCall::class];
return [FuncCall::class];
}

/**
* @param Node\Expr\FuncCall $node
* @param FuncCall $node
*/
public function refactor(Node $node): ?Node
{
Expand All @@ -75,7 +77,7 @@ public function refactor(Node $node): ?Node
}

if ($target !== null) {
return new Node\Expr\ClassConstFetch(new Node\Name([$target]), new Node\VarLikeIdentifier('class'));
return new ClassConstFetch(new Name([$target]), new VarLikeIdentifier('class'));
}

return null;
Expand Down

0 comments on commit 1afc647

Please sign in to comment.