rectorphp / rector

Instant Upgrades and Automated Refactoring of any PHP 5.3+ code
https://getrector.com
MIT License
8.32k stars 670 forks source link

Incorrect behavior of AddMethodCallBasedStrictParamTypeRector #8629

Closed samsonasik closed 3 weeks ago

samsonasik commented 3 weeks ago

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/dfcfecf6-f9bf-4c36-98ac-5fa5704e5f4d

<?php

use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;

final class SkipMoreDetailType
{
    /**
     * @param Name $node
     */
    public function run(Node $node)
    {
        if ($node instanceof FullyQualified) {
            return;
        }

        $this->execute($node);
    }

    private function execute(Name $node)
    {
    }
}

Responsible rules

Expected Behavior

This should be skipped as Name is more detailed type then Node, and it cause phpstan notice:

 ------------------------------------------------------------------------
  - '#Parameter 1 should use "PhpParser\\Node\\Name" type as the only type passed to this method#'
 ------------------------------------------------------------------------