Skip to content
Discussion options

You must be logged in to vote

It seems you can create custom rector rule for that, which uses Class_ as node type, and check with the PhpDocInfo service, eg:

use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;

public function __construct(private readonly PhpDocInfoFactory $phpDocInfoFactory)
{
}

public function refactor(Node $node): ?Node
{
    // check class has __call method 
    if (! $node->getMethod('__call') instanceof ClassMethod) {
        return null;
    } 

    $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
    $method = $phpDocInfo->getByName(MethodTagValueNode::class);

    if ($method instanceof MethodTagValueNode) {
        // check metho…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by samsonasik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants