Enumerations
An enumerated type – enum for short – is a special type that has a constrained list of possible values, or enumerators.
If you would like to learn more background on this topic, you can read the lengthy Wikipedia article at https://w.wiki/3i7Z. However, the sentence at the start of this section does pretty much sum it up.
To understand the PHP implementation of enums, the best place to look at the time of writing is the RFC page:
PHP: rfc:enumerations
https://wiki.php.net/rfc/enumerations
Basic and backed enums
One way to think of enums is a bit like a constant array. Something that is hardcoded and can never change when the code is running. There are two kinds of enums – basic (or pure) and backed. These two types of enums correlate conceptually somewhat with indexed and associative arrays, in that a basic enum has just the value, and backed enums have a key and a value associated with that key.
Like associative array keys, backed...