Skip to content

is_a is not correctly removing class-string type in a falsey scope #6704

@herndlm

Description

@herndlm

Bug report

Sorry, digging up another weird exotic edge case here.. In general is_a is working quite well, but there are problems with class-string types in a falsey scope only. Object types in a falsey scope work just fine.

As is_subclass_of works really similar and both of them have type specyfing extensions, I assume there could be similar problems there. So maybe something found via https://github.com/phpstan/phpstan/issues?q=is%3Aissue+is%3Aopen+is_subclass_of is related

Maybe phpstan/phpstan-src#1039 is related too and we can take over adaptions from there. I did not thoroughly check yet tbh.

I'm happy to try fixing this myself later.

Code snippet that reproduces the problem

https://phpstan.org/r/6823a8c6-a4f2-456b-a7d5-995b70feef2d

Expected output

No errors.

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

Initially I thought there are more problems with is_a, then I figured out I was testing wrong and PHPStan outsmarted me again ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions