PHP/enum
from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< PHP
|
PHP enum support
|
{{#set: page title=PHP enum support }}
Methods
| definition | defined in |
|---|---|
| public static cases(): array | UnitEnum |
| public static tryFrom(int or string $value): ?static | BackedEnum |
| public static from(int or string $value): static | BackedEnum |
| public string $name | UnitEnum |
| public int or string $value | BackedEnum |
Documentation
- Enumerations:
UnitEnum:BackedEnum:
Sample Code
To get a UnitEnum enum from a case name (equivalent to from()/tryFrom()):
- constant("<enum name>::{$value}")
