webmozarts / assert

Assertions to validate method input/output with nice error messages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertion generate UnusedMethodCall with Psalm

theofidry opened this issue · comments

I have something along the lines of:

class Foo {
     public function getAggregateClass(): ?string
    {
        Assert::nullOrImplementsInterface(
            $this->aggregateClass,
            Identifiable::class,
            'Expected the aggregate class name to refer to an implementation of %2$s. Got: %s'
        );

        return $this->aggregateClass;
    }
}

The assertion ::nullOrImplementsInterface() generates a UnusedMethodCall issue. Note that Assert::implementsInterface() does not hence this is likely an issue with the null* variants.

Tested on:

  • PHP 7.4.13
  • Psalm 4.3.1@2feba22a005a18bf31d4c7b9bdb9252c73897476
  • webmozart/assert 1.9.1

Would it be too much to ask you setup a little test repository with all dependencies and configuration set up?

Otherwise, if no one will look at it I think I can have some time later this week.

I'll try to have a look at it ASAP