final class EnumType extends ClassLike

Definition of an enum with cases, methods, constants and traits.

Methods

setType(string|null $type)

Sets the backing type of a backed enum ('int' or 'string').

string|null
getType()

Returns the backing type ('int' or 'string'), or null for a pure enum.

setImplements(array $names)

No description

array
getImplements()

No description

addImplement(string $name)

No description

removeImplement(string $name)

No description

setCases(array $cases)

Replaces all cases.

array
getCases()

No description

addCase(string $name, Literal|null $value = null, bool $overwrite = false)

Adds a case to the enum.

removeCase(string $name)

No description

addMember(TraitUse $member, bool $overwrite = false)

Adds a member to the enum.

void
__clone()

No description

Details

at line 33
EnumType setType(string|null $type)

Sets the backing type of a backed enum ('int' or 'string').

Parameters

string|null $type

Return Value

EnumType

at line 43
string|null getType()

Returns the backing type ('int' or 'string'), or null for a pure enum.

Return Value

string|null

at line 50
EnumType setImplements(array $names)

No description

Parameters

array $names

Return Value

EnumType

at line 59
array getImplements()

No description

Return Value

array

at line 65
EnumType addImplement(string $name)

No description

Parameters

string $name

Return Value

EnumType

at line 73
EnumType removeImplement(string $name)

No description

Parameters

string $name

Return Value

EnumType

at line 84
EnumType setCases(array $cases)

Replaces all cases.

Parameters

array $cases

Return Value

EnumType

at line 97
array getCases()

No description

Return Value

array

at line 107
EnumCase addCase(string $name, Literal|null $value = null, bool $overwrite = false)

Adds a case to the enum.

Parameters

string $name
Literal|null $value
bool $overwrite

Return Value

EnumCase

Exceptions

InvalidStateException

at line 117
EnumType removeCase(string $name)

No description

Parameters

string $name

Return Value

EnumType

at line 128
EnumType addMember(TraitUse $member, bool $overwrite = false)

Adds a member to the enum.

Parameters

TraitUse $member
bool $overwrite

Return Value

EnumType

Exceptions

InvalidStateException

at line 145
void __clone()

No description

Return Value

void

Traits