webmozarts / assert

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

implementsInterface does not pass psalm validation when passed an object

githoober opened this issue · comments

The snippet below mimics the logic from implementsInterface
https://psalm.dev/r/9362046866

With an object passed to implementsInterface Assert produces the following error:

ERROR: TypeDoesNotContainType - 33:1 - Cannot resolve types for $a - A does not contain class-string<ExpectedType:fn-implementsinterface as I>

With a call get_class on the object, psalm validation passes.

Looks like a psalm bug

assert-implements tests is missing a test case for passing an object. I wonder if this case is even supported, as the assertion is made $value is a string:

@psalm-assert class-string<ExpectedType> $value

I have managed to fix it. Will probably provide a PR:

https://psalm.dev/r/4e5e7b02bb

Hm, doesn't the second @psalm-assert simply overwrite the first one?

Also ran into this issue today. Had to use get_class() instead.