SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
37 stars 7 forks source link

No error highlight in traits #65

Closed MrMeshok closed 3 months ago

MrMeshok commented 3 months ago

Take this file for example

Trait TestTrait
{
    public function getFromNullable(?stdClass $stdClass): mixed
    {
        return $stdClass->foo;
    }
}

class FirstClass
{
    use TestTrait;
}

class SecondClass
{
    use TestTrait;

    public function getFromNullableClass(?stdClass $stdClass): mixed
    {
        return $stdClass->foo;
    }
}

In VS Code I see this image

But if i run phpstan in terminal image

I also found this blog about traits https://phpstan.org/blog/how-phpstan-analyses-traits

SanderRonde commented 3 months ago

Thanks for the report! (You're on a roll :))

I've got some good news and some bad news:

MrMeshok commented 3 months ago

Awesome! I actually didn't expect to see error in a class that uses the trait. And after reading this blog post it's definitely not needed