HumHub Documentation (unofficial)

Method extends Enum
in package

Methods enum

Tags
@method

(): Method

@method

(): Method

psalm-immutable
psalm-template

int

extends

Enum

Table of Contents

Constants

DEFLATE  = 0x8
STORE  = 0x0

Properties

$cache  : array<string|int, mixed>
Store existing constants in a static cache per object.
$instances  : array<string|int, mixed>
Cache of instances of the Enum class
$value  : mixed
Enum value
$key  : string
Enum key, the constant name

Methods

__callStatic()  : static
Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
__construct()  : mixed
Creates a new value of some type
__toString()  : string
__wakeup()  : mixed
This method exists only for the compatibility reason when deserializing a previously serialized version that didn't had the key property
assertValidValue()  : void
Asserts valid enum value
equals()  : bool
Determines if Enum should be considered equal with the variable passed as a parameter.
from()  : static
getKey()  : string
Returns the enum key (i.e. the constant name).
getValue()  : mixed
isValid()  : bool
Check if is valid enum value
isValidKey()  : bool
Check if is valid enum key
jsonSerialize()  : mixed
Specify data which should be serialized to JSON. This method returns data that can be serialized by json_encode() natively.
keys()  : array<string|int, mixed>
Returns the names (keys) of all constants in the Enum class
search()  : string|false
Return key for value
toArray()  : array<string|int, mixed>
Returns all possible values as an array
values()  : array<string|int, static>
Returns instances of the Enum class of all Enum constants
assertValidValueReturningKey()  : string
Asserts valid enum value

Constants

DEFLATE

public mixed DEFLATE = 0x8

Properties

$cache

Store existing constants in a static cache per object.

protected static array<string|int, mixed> $cache = []
Tags
psalm-var

array<class-string, array<string, mixed>>

$instances

Cache of instances of the Enum class

protected static array<string|int, mixed> $instances = []
Tags
psalm-var

array<class-string, array<string, static>>

$value

Enum value

protected mixed $value
Tags
psalm-var

T

$key

Enum key, the constant name

private string $key

Methods

__callStatic()

Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant

public static __callStatic(string $name, array<string|int, mixed> $arguments) : static
Parameters
$name : string
$arguments : array<string|int, mixed>
Tags
throws
BadMethodCallException
psalm-pure
Return values
static

__construct()

Creates a new value of some type

public __construct(mixed $value) : mixed
Parameters
$value : mixed
Tags
psalm-pure
psalm-param

T $value

throws
UnexpectedValueException

if incompatible type is given.

__toString()

public __toString() : string
Tags
psalm-pure
psalm-suppress

InvalidCast

Return values
string

__wakeup()

This method exists only for the compatibility reason when deserializing a previously serialized version that didn't had the key property

public __wakeup() : mixed

assertValidValue()

Asserts valid enum value

public static assertValidValue(mixed $value) : void
Parameters
$value : mixed
Tags
psalm-pure
psalm-assert

T $value

equals()

Determines if Enum should be considered equal with the variable passed as a parameter.

public final equals([mixed $variable = null ]) : bool

Returns false if an argument is an object of different class or not an object.

This method is final, for more information read https://github.com/myclabs/php-enum/issues/4

Parameters
$variable : mixed = null
Tags
psalm-pure
psalm-param

mixed $variable

Return values
bool

from()

public static from(mixed $value) : static
Parameters
$value : mixed
Return values
static

getKey()

Returns the enum key (i.e. the constant name).

public getKey() : string
Tags
psalm-pure
Return values
string

getValue()

public getValue() : mixed
Tags
psalm-pure
psalm-return

T

isValid()

Check if is valid enum value

public static isValid(mixed $value) : bool
Parameters
$value : mixed
Tags
psalm-param

mixed $value

psalm-pure
psalm-assert-if-true

T $value

Return values
bool

isValidKey()

Check if is valid enum key

public static isValidKey(mixed $key) : bool
Parameters
$key : mixed
Tags
psalm-param

string $key

psalm-pure
Return values
bool

keys()

Returns the names (keys) of all constants in the Enum class

public static keys() : array<string|int, mixed>
Tags
psalm-pure
psalm-return

list

Return values
array<string|int, mixed>

Return key for value

public static search(mixed $value) : string|false
Parameters
$value : mixed
Tags
psalm-param

mixed $value

psalm-pure
Return values
string|false

toArray()

Returns all possible values as an array

public static toArray() : array<string|int, mixed>
Tags
psalm-pure
psalm-suppress

ImpureStaticProperty

psalm-return

array<string, mixed>

Return values
array<string|int, mixed>

Constant name in key, constant value in value

values()

Returns instances of the Enum class of all Enum constants

public static values() : array<string|int, static>
Tags
psalm-pure
psalm-return

array<string, static>

Return values
array<string|int, static>

Constant name in key, Enum instance in value

assertValidValueReturningKey()

Asserts valid enum value

private static assertValidValueReturningKey(mixed $value) : string
Parameters
$value : mixed
Tags
psalm-pure
psalm-assert

T $value

Return values
string

        
On this page

Search results