Skip to content

Improved Enum support with regard to comparisons #7052

@Seldaek

Description

@Seldaek

Feature request

I am in the process of converting existing code to use enums in Monolog, and I noticed that PHPStan wasn't being as helpful as it could be.

See https://phpstan.org/r/920189df-c1f3-4b59-a816-02b8369fb16f for some expected errors which are missing.

See also https://3v4l.org/I2MUn#v8.1.5 for actual output.

The TL;DR is that when you have code like if ($foo < $bar) and then you convert it to enums and suddenly $foo and $bar are enum cases instead of int values, your code breaks but PHPStan does not tell you that this will now always return false.

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