psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Psalm don't analyze unused traits

Open vjik opened this issue 10 months ago • 1 comments

Without "use" no issues: https://psalm.dev/r/6d64d83015

With "use" has issues: https://psalm.dev/r/c174834679

vjik avatar Apr 25 '24 17:04 vjik

I found these snippets:

https://psalm.dev/r/6d64d83015
<?php

trait ArrayableTrait
{
    public function fields(): array
    {
        return UnknownFn();
    }
}
Psalm output (using commit 08afc45):

No issues!
https://psalm.dev/r/c174834679
<?php

trait ArrayableTrait
{
    public function fields(): array
    {
        return UnknownFn();
    }
}

class Test {
    use ArrayableTrait;
}
Psalm output (using commit 08afc45):

ERROR: UndefinedFunction - 7:16 - Function UnknownFn does not exist

psalm-github-bot[bot] avatar Apr 25 '24 17:04 psalm-github-bot[bot]