Documentation

EnumMap implements ArrayAccess, Countable, IteratorAggregate

Tags
implements

ArrayAccess<Enum, mixed>

implements

IteratorAggregate<string, mixed>

see
https://www.php.net/manual/en/class.arrayaccess.php
see
https://www.php.net/manual/en/class.countable.php
see
https://www.php.net/manual/en/class.iteratoraggregate.php
phpstan-template

TKey of Enum

phpstan-template

TValue

phpstan-implements

ArrayAccess<TKey, TValue>

phpstan-implements

IteratorAggregate<string, TValue>

psalm-template

TKey of Enum

psalm-template

TValue

template-implements

ArrayAccess<TKey, TValue>

template-implements

IteratorAggregate<string, TValue>

Interfaces, Classes and Traits

ArrayAccess
Countable
IteratorAggregate

Table of Contents

$keys  : array<int, Enum>
$typedArray  : TypedArray<Enum, mixed>
count()  : int
getIterator()  : Traversable<string, mixed>
isEmpty()  : bool
Determines if the enum map is empty or not.
new()  : EnumMap<Enum, mixed>
Creates a new instance of the enum map with the specified enum type key.
offsetExists()  : bool
offsetGet()  : mixed|null
offsetSet()  : void
offsetUnset()  : void
toArray()  : array<string, object>
Gets the enum map of values as a plain array.
withArrayValue()  : EnumMap<Enum, array<int|string, mixed>>
Returns a new instance of the enum map with the array type value.
withBoolValue()  : EnumMap<Enum, bool>
Returns a new instance of the enum map with the bool type value.
withClassValue()  : EnumMap<Enum, object>
Returns a new instance of the enum map with the specified class type value.
withFloatValue()  : EnumMap<Enum, float>
Returns a new instance of the enum map with the float type value.
withInterfaceValue()  : EnumMap<Enum, object>
Returns a new instance of the enum map with the class type value that implements the specified interface.
withIntValue()  : EnumMap<Enum, int>
Returns a new instance of the enum map with the int type value.
withMixedValue()  : EnumMap<Enum, mixed>
Returns a new instance of the enum map with the mixed type value.
withObjectValue()  : EnumMap<Enum, object>
Returns a new instance of the enum map with the object type value.
withResourceValue()  : EnumMap<Enum, resource>
Returns a new instance of the enum map with the resource type value.
withStringValue()  : EnumMap<Enum, string>
Returns a new instance of the enum map with the string type value.
withTraitValue()  : EnumMap<Enum, object>
Returns a new instance of the enum map with the class type value that uses the specified trait.
__construct()  : mixed
validateEnum()  : void

Properties

$keys

private array<int, Enum> $keys = []
Tags
phpstan-var

array<int, TKey>

psalm-var

array<int, TKey>

$typedArray

private TypedArray<Enum, mixed> $typedArray
Tags
phpstan-var

TypedArray<TKey, TValue>

psalm-var

TypedArray<TKey, TValue>

Methods

isEmpty()

Determines if the enum map is empty or not.

public isEmpty() : bool
Return values
bool

new()

Creates a new instance of the enum map with the specified enum type key.

public static new(string $class) : EnumMap<Enum, mixed>
Parameters
$class : string
Tags
phpstan-template

TEnum of Enum

phpstan-param

class-string $class

phpstan-return

EnumMap<TEnum, mixed>

psalm-template

TEnum of Enum

psalm-param

class-string $class

psalm-return

EnumMap<TEnum, mixed>

Return values
EnumMap<Enum, mixed>

toArray()

Gets the enum map of values as a plain array.

public toArray() : array<string, object>
Tags
phpstan-return

array<string, TValue>

psalm-return

array<string, TValue>

Return values
array<string, object>

withArrayValue()

Returns a new instance of the enum map with the array type value.

public withArrayValue() : EnumMap<Enum, array<int|string, mixed>>
Tags
phpstan-return

EnumMap<TKey, array<int|string, mixed>>

psalm-return

EnumMap<TKey, array<int|string, mixed>>

Return values
EnumMap<Enum, array<int|string, mixed>>

withBoolValue()

Returns a new instance of the enum map with the bool type value.

public withBoolValue() : EnumMap<Enum, bool>
Tags
phpstan-return

EnumMap<TKey, bool>

psalm-return

EnumMap<TKey, bool>

Return values
EnumMap<Enum, bool>

withClassValue()

Returns a new instance of the enum map with the specified class type value.

public withClassValue(string $class) : EnumMap<Enum, object>
Parameters
$class : string
Tags
phpstan-template

TClass

phpstan-param

class-string $class

phpstan-return

EnumMap<TKey, TClass>

psalm-template

TClass

psalm-param

class-string $class

psalm-return

EnumMap<TKey, TClass>

Return values
EnumMap<Enum, object>

withFloatValue()

Returns a new instance of the enum map with the float type value.

public withFloatValue() : EnumMap<Enum, float>
Tags
phpstan-return

EnumMap<TKey, float>

psalm-return

EnumMap<TKey, float>

Return values
EnumMap<Enum, float>

withInterfaceValue()

Returns a new instance of the enum map with the class type value that implements the specified interface.

public withInterfaceValue(string $interface) : EnumMap<Enum, object>
Parameters
$interface : string
Tags
phpstan-template

TInterface

phpstan-param

class-string $interface

phpstan-return

EnumMap<TKey, TInterface>

psalm-template

TInterface

psalm-param

class-string $interface

psalm-return

EnumMap<TKey, TInterface>

Return values
EnumMap<Enum, object>

withIntValue()

Returns a new instance of the enum map with the int type value.

public withIntValue() : EnumMap<Enum, int>
Tags
phpstan-return

EnumMap<TKey, int>

psalm-return

EnumMap<TKey, int>

Return values
EnumMap<Enum, int>

withMixedValue()

Returns a new instance of the enum map with the mixed type value.

public withMixedValue() : EnumMap<Enum, mixed>
Tags
phpstan-return

EnumMap<TKey, mixed>

psalm-return

EnumMap<TKey, mixed>

Return values
EnumMap<Enum, mixed>

withObjectValue()

Returns a new instance of the enum map with the object type value.

public withObjectValue() : EnumMap<Enum, object>
Tags
phpstan-return

EnumMap<TKey, object>

psalm-return

EnumMap<TKey, object>

Return values
EnumMap<Enum, object>

withResourceValue()

Returns a new instance of the enum map with the resource type value.

public withResourceValue() : EnumMap<Enum, resource>
Tags
phpstan-return

EnumMap<TKey, resource>

psalm-return

EnumMap<TKey, resource>

Return values
EnumMap<Enum, resource>

withStringValue()

Returns a new instance of the enum map with the string type value.

public withStringValue() : EnumMap<Enum, string>
Tags
phpstan-return

EnumMap<TKey, string>

psalm-return

EnumMap<TKey, string>

Return values
EnumMap<Enum, string>

withTraitValue()

Returns a new instance of the enum map with the class type value that uses the specified trait.

public withTraitValue(string $trait) : EnumMap<Enum, object>
Parameters
$trait : string
Tags
phpstan-param

class-string $trait

phpstan-return

EnumMap<TKey, object>

psalm-param

trait-string $trait

psalm-return

EnumMap<TKey, object>

Return values
EnumMap<Enum, object>

__construct()

private __construct(TypedArray<Enum, mixed> $typedArray) : mixed
Parameters
$typedArray : TypedArray<Enum, mixed>
Tags
phpstan-param

TypedArray<TKey, TValue> $typedArray

psalm-param

TypedArray<TKey, TValue> $typedArray

Return values
mixed

validateEnum()

private static validateEnum(string $class) : void
Parameters
$class : string
Tags
phpstan-param

class-string $class

psalm-param

class-string $class

Return values
void

Search results