PHP/native/UnitEnum: Difference between revisions
from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
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. | 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== | |||
* {{l/php/keyword|match}}() | |||
Revision as of 13:59, 25 August 2024
Note that this (pseudo)Template:L/php cannot actually be implemented as a standard Template:L/php; it can only be (pseudo)implemented by declaring an Template:L/php.
If an enum is "backed" (declared as having a scalar value for each choice), it will implement this interface but also the Template:L/same 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:
- Template:Fmt/arg (int) => Template:Fmt/arg (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.
