Skip to content

Support @phpstan-require-extends and calls of methods of this class #3256

Open
@momala454

Description

@momala454

Feature description or problem with existing feature
@phpstan-require-extends on a trait force the trait to be used on a specific class.
When I call a method of that specific class on the trait, intelephense does not know the references.
Phpstan even know the references to this method even without @phpstan-require-extends

/** @phpstan-require-extends HelloWorld */
trait Hello
{
    public function world(): void
    {
        $a = $this->hi(); // $a is mixed instead of int, "hi" is unknown to intelephense
    }
}

class HelloWorld
{
    use Hello;

// here 0 references instead of 1
    public function hi(): int
    {
        return 1;
    }
}

Image

Describe the solution you'd like
It could be cool for intelephense to know the references to the calls of "hi". It could use @phpstan-require-extends if that help to find it

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions