1.2.1254. Undefined Enumcase

The enumeration case does not exists. It may be a class constant, defined in the same enumeration.

<?php

enum theEnum {
    case A; // an enum case

    // a constant
    const C = 1;
}

function foo(theEnum $a) {}

foo(theEnum::A);
foo(theEnum::C);

?>

1.2.1254.2. Connex PHP features

1.2.1254.2.1. Specs

Short name

Enums/UndefinedEnumcase

Rulesets

All, Analyze, Changed Behavior, Class Review

Exakat since

2.3.6

PHP Version

With PHP 8.1 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Related rule

Unused Enumeration Case

Available in

Entreprise Edition, Exakat Cloud