Skip to content

Checking is_subclass_of in enum trait results in always{False,True} errors #12798

@calebdw

Description

@calebdw

Bug report

Hello!

Traits are the only way to add reusable logic to enums given that they do not allow inheritance. As such, it's often necessary to check for BackdEnum or other interfaces before calling methods / accessing properties.

However, PHPStan throws always{False,True} errors since the trait is analyzed in the context of the specific enum.

Code snippet that reproduces the problem

https://phpstan.org/r/f13c0bc4-6e0a-43c4-8c7d-154ba6266935

Expected output

I'm not sure what the ideal solution is....but I'd rather not have to manually ignore these if possible.

However, I'm okay with ignoring these if there's no easy solution.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions