Duplicate Enum Cases Are Not Linted Anymore
Two different cases in an enumeration cannot have duplicate values.
In PHP 8.1, it was a compilation error, and the code would not be executed.
Since PHP 8.2, it is only checked at execution time, when the enumeration is first used. This means that it may be a hidden bug, until that code is actually used.
PHP code
<?php
enum A : int{
case A = 1;
case B = 1;
}
function foo(?A $x = null) {
var_dump($x);
}
// A is not used, as it default to NULL
foo();
?>
Before
Fatal error: Duplicate value in enum A for cases A and B
After
NULL
PHP version change
This behavior changed in 8.2.