Skip to content

class-string variance not respected in instanceof (unless using @template) #3761

@dktapps

Description

@dktapps

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/7bf13ee0-c86c-448a-8d5b-2e59cb95d5ac

https://phpstan.org/r/a9895ddd-6838-4652-9c02-32d9f503bd21

The second code sample reports an always-true error, which we can see is bogus here: https://3v4l.org/gvWt5

However, if using a @template T of NamedTag and @param class-string<T>, the error goes away.

Expected output

Both samples should have no errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions