Difference between revisions of "PHP/native/BackedEnum"
< PHP
Jump to navigation
Jump to search
(pseudocode in official doc did not include "function" in method declarations) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
interface BackedEnum extends UnitEnum { | interface BackedEnum extends UnitEnum { | ||
− | static from(int|string $value): static; | + | static function from(int|string $value): static; |
− | static tryFrom(int|string $value): ?static; | + | static function tryFrom(int|string $value): ?static; |
string|int $value; // pseudocode | string|int $value; // pseudocode | ||
− | // | + | // INHERITED from UnitEnum (unmodified): |
− | |||
− | + | static function cases(): array; | |
string $name; // pseudocode | string $name; // pseudocode | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | The member-variables are labelled "pseudocode" because a normal interface can't declare member-variables | + | The member-variables are labelled "pseudocode" because a normal {{l/php|interface}} can't declare member-variables. |
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 14:24, 25 August 2024
BackedEnum pseudointerface manual page: The BackedEnum interface
|
Note that this (pseudo)interface cannot actually be implemented as a standard class; it can only be (pseudo)implemented by declaring a backed enum.
Definition
interface BackedEnum extends UnitEnum {
static function from(int|string $value): static;
static function tryFrom(int|string $value): ?static;
string|int $value; // pseudocode
// INHERITED from UnitEnum (unmodified):
static function cases(): array;
string $name; // pseudocode
}
The member-variables are labelled "pseudocode" because a normal interface can't declare member-variables.