Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementsInterface does not pass psalm validation when passed an object #205

Open
githoober opened this issue Jun 26, 2020 · 5 comments
Open

Comments

@githoober
Copy link

githoober commented Jun 26, 2020

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.

@githoober githoober changed the title implementsInterface does not validate with psalm when passed an object implementsInterface does not pass psalm validation when passed an object Jun 26, 2020
@zerkms
Copy link
Contributor

zerkms commented Jun 26, 2020

Looks like a psalm bug

@githoober
Copy link
Author

githoober commented Jun 30, 2020

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

@githoober
Copy link
Author

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

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

@zerkms
Copy link
Contributor

zerkms commented Jun 30, 2020

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

@devbanana
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants