1.2.388. Duplicate Enum Case Value

In a backed enumeration, may it be int or string, the values of the cases must all be distinct. There can’t be two of them of the same value.

<?php

enum e: int {
     case A = 1 + 1;
     case B = 2;
}

enum e2: string {
     case A = 'A';
     case B = 'A';
}

?>

1.2.388.2. Connex PHP features

1.2.388.2.1. Specs

Short name

Enums/DuplicateCaseValue

Rulesets

All, Analyze, LintButWontExec

Exakat since

2.6.8

PHP Version

With PHP 8.1 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud