Skip to content

PhpStan does not understand the backed value of enums #8828

@bendavies

Description

@bendavies

Bug report

It seems that phpstan does not know that self::Foo->value in the below example is a string.
The enum is string backed, while phpstan thinks the value could be string|int

Code snippet that reproduces the problem

https://phpstan.org/r/ad018c7e-3eb6-4b13-ae38-254707335b82

PHPDoc tag @var for constant AStringBackedEnum::ZIP_CODE_MAPPING with type array<string, array<int, string>> is incompatible with value non-empty-array<int|string, 'yeah'>.

Expected output

No error

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

Every day buddy!

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