Documentation

AbstractEnum
in package

Table of Contents

$allValuesLoaded  : array<string, bool>
$constants  : array<string, array<string|int, mixed>>
$name  : string
$ordinal  : int
$values  : array<string, array<string, static>>
__callStatic()  : static
Magic getter which forwards all calls to {@see self::valueOf()}.
__clone()  : mixed
Forbid cloning enums.
__sleep()  : array<string|int, mixed>
Forbid serializing enums.
__toString()  : string
Turns the enum into a string representation.
__wakeup()  : void
Forbid unserializing enums.
compareTo()  : int
Compares this enum with the specified object for order.
name()  : string
Returns the name of this enum constant, exactly as declared in its enum declaration.
ordinal()  : int
Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).
valueOf()  : static
Returns an enum with the specified name.
values()  : array<string|int, static>
Obtains all possible types defined by this enum.
__construct()  : mixed
The constructor is private by default to avoid arbitrary enum creation.
constants()  : array<string|int, mixed>
createValue()  : static

Properties

$allValuesLoaded

private static array<string, bool> $allValuesLoaded = []

$constants

private static array<string, array<string|int, mixed>> $constants = []

$values

private static array<string, array<string, static>> $values = []

Methods

__callStatic()

Magic getter which forwards all calls to {@see self::valueOf()}.

public final static __callStatic(string $name, array<string|int, mixed> $arguments) : static
Parameters
$name : string
$arguments : array<string|int, mixed>
Return values
static

__toString()

Turns the enum into a string representation.

public __toString() : string

You may override this method to give a more user-friendly version.

Return values
string

compareTo()

Compares this enum with the specified object for order.

public final compareTo(self $other) : int

Returns negative integer, zero or positive integer as this object is less than, equal to or greater than the specified object.

Enums are only comparable to other enums of the same type. The natural order implemented by this method is the order in which the constants are declared.

Parameters
$other : self
Tags
throws
MismatchException

if the passed enum is not of the same type

Return values
int

name()

Returns the name of this enum constant, exactly as declared in its enum declaration.

public final name() : string

Most programmers should use the self::__toString() method in preference to this one, as the toString method may return a more user-friendly name. This method is designed primarily for use in specialized situations where correctness depends on getting the exact name, which will not vary from release to release.

Return values
string

ordinal()

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).

public final ordinal() : int

Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data structures.

Return values
int

valueOf()

Returns an enum with the specified name.

public final static valueOf(string $name) : static

The name must match exactly an identifier used to declare an enum in this type (extraneous whitespace characters are not permitted).

Parameters
$name : string
Tags
throws
IllegalArgumentException

if the enum has no constant with the specified name

Return values
static

values()

Obtains all possible types defined by this enum.

public final static values() : array<string|int, static>
Return values
array<string|int, static>

__construct()

The constructor is private by default to avoid arbitrary enum creation.

private __construct() : mixed

When creating your own constructor for a parameterized enum, make sure to declare it as protected, so that the static methods are able to construct it. Avoid making it public, as that would allow creation of non-singleton enum instances.

Return values
mixed

constants()

private static constants() : array<string|int, mixed>
Return values
array<string|int, mixed>

createValue()

private static createValue(string $name, int $ordinal, array<string|int, mixed> $arguments) : static
Parameters
$name : string
$ordinal : int
$arguments : array<string|int, mixed>
Return values
static

Search results