PHP/native/UnitEnum
Jump to navigation
Jump to search
UnitEnum pseudointerface manual page: The UnitEnum interface
|
Note that this (pseudo)interface cannot actually be implemented as a standard class; it can only be (pseudo)implemented by declaring an enum.
If an enum is "backed" (declared as having a scalar value for each choice), it will implement this interface but also the BackedEnum interface.)
Definition
interface UnitEnum {
static function cases(): array
string $name; // pseudocode
}
The member-variable is labelled "pseudocode" because a normal interface can't declare member-variables.
cases()
This method returns an array containing one element for each case in the enum:
- <array index> (int) => <enum case-object> (BackedEnum)
This list can then be used to build other arrays indexing the enum class's names and/or any other information known to each case.
See Also
match
()