Skip to content

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

Open

Description

@githoober

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.

Activity

  1. changed the title [-]implementsInterface does not validate with psalm when passed an object[/-] [+]implementsInterface does not pass psalm validation when passed an object[/+] on Jun 26, 2020
  2. zerkms commented on Jun 26, 2020

    @zerkms
    Contributor

    Looks like a psalm bug

  3. githoober commented on Jun 30, 2020

    @githoober
    Author

    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

  4. githoober commented on Jun 30, 2020

    @githoober
    Author

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

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

  5. zerkms commented on Jun 30, 2020

    @zerkms
    Contributor

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

  6. devbanana commented on Jan 25, 2022

    @devbanana

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions