Skip to content

MIR0718

DuplicateEnumCaseValue

Every case of a backed enum needs its own value. PHP stops with a fatal error when two cases share one; the later case is reported.

<?php
enum Status: int {
case Active = 1;
case Enabled = 1; // Error: duplicate of Active
}

Give the case its own value, or drop it and use the existing case:

<?php
enum Status: int {
case Active = 1;
case Enabled = 2;
}