Skip to content

Add rule to check for checking value in match or switch instruction #32

@jdecool

Description

@jdecool

Example:

/**
 * @extends Enum<int>
 */
class MyEnum extends Enum
{
    public const FOO = 1;
    public const BAR = 2;

    public function getLabel(): string {
        return match ($this->value) {
            self::FOO => 'foo-value',
            self::BAR => 'bar-value',
        };
    }
}

Will output errors because it phpstan consider that values from ]-ING;0] and [3;+INF] are not checked.

Metadata

Metadata

Assignees

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