Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rectify #6408

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Rectify #6408

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
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