Skip to content

Call to function is_subclass_of() is reported as always being evaluated as true #8464

@remi-san

Description

@remi-san

Bug report

Call to function is_subclass_of() with object and class-string is reported as always being evaluated as true, even if it can't possibly know the type of the object given nor the class described by the class-string.

It also happens with class-string and class-string.

Using PHP 8.1.13 & PHPStan 1.9.2

Code snippet that reproduces the problem

https://phpstan.org/r/fc3cdcea-02db-4aba-b64d-9da9170288fa

https://phpstan.org/r/9103b780-22c7-4c38-9dd7-f8933540ceff

Expected output

PHPStan should not report any error if it can't know whether one is subclass of the other before execution.

Did PHPStan help you today? Did it make you happy in any way?

It helped me a lot defining more precisely the types for my app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions