PHP/enum
< PHP
Jump to navigation
Jump to search
PHP enum support
|
Methods
kind of thing | name | returns | defined in |
---|---|---|---|
static function | cases() | array | UnitEnum |
static function final | tryFrom(int or string $value) | ?static | BackedEnum |
static function final | from(int or string $value) | static | BackedEnum |
dynamic property | $name | string | (UnitEnum) |
dynamic property | $value | int or string | (BackedEnum) |
Documentation
official
- Enumerations:
- Basic:
- Backed:
3rd party
Sample Code
To get a UnitEnum enum from a case name (equivalent to from()/tryFrom()):
- constant("<enum name>::{$value}")