Typed By Enum
<?php
enum e {
case A;
const B = 1;
}
var_dump(e::A instanceof e);
var_dump(e::B instanceof e);
?>
Enumeration cannot be instantiated into an object. In fact, the cases of the enumeration are the objects. Hence, a case object has the enumeration type.
Then, an enumeration (class) constant cannot be confused with a case, because the enumeration cannot be instantiated, and class constants also do not support new initializers.
See Also
- Enumeration (PHP manual)
- Typing with enum [Try me]
PHP Features
Last updated: 10 September 2026