class NikicEnumNode implements EnumNode (View source)

Adapter for nikic/php-parser Enum_ nodes.

Wraps Enum_ and provides parser-agnostic access to enum properties.

Traits

Renders a class-like reference (parent class, implemented interface, parent interface) while preserving whether the source wrote it fully qualified.

Methods

__construct(Enum_ $enum)

No description

string
getName()

Get the enum name.

string
getNamespace()

Get the enum namespace.

void
setNamespace(string $namespace)

Set the namespace for this enum.

TypeNode|null
getBackingType()

Get the backing type for backed enums (string or int), or null for unit enums.

array
getCaseNames()

Get enum case names.

array
getMethods()

Get the enum methods.

array
getImplementedInterfaceNames()

Get implemented interface names.

bool
isFinal()

Whether the enum is declared with the final keyword in the source.

array
getConstants()

Get the enum constants.

getDocComment()

Get the doc comment, or null if no doc comment.

array
getAttributes()

Get the attributes for this enum.

Details

__construct(Enum_ $enum)

No description

Parameters

Enum_ $enum

string getName()

Get the enum name.

Return Value

string

string getNamespace()

Get the enum namespace.

Return Value

string

void setNamespace(string $namespace)

Set the namespace for this enum.

Parameters

string $namespace

Return Value

void

TypeNode|null getBackingType()

Get the backing type for backed enums (string or int), or null for unit enums.

Return Value

TypeNode|null

array getCaseNames()

Get enum case names.

Return Value

array

array getMethods()

Get the enum methods.

Return Value

array

array getImplementedInterfaceNames()

Get implemented interface names.

Return Value

array

bool isFinal()

Whether the enum is declared with the final keyword in the source.

PHP does not support final enum syntax, so this returns false for stub enum nodes. Reflection may report true (PHP 8.2+) due to implicit finality. The validator compares this against reflection to detect mismatches.

Return Value

bool

array getConstants()

Get the enum constants.

Return Value

array

DocCommentNode|null getDocComment()

Get the doc comment, or null if no doc comment.

Return Value

DocCommentNode|null

array getAttributes()

Get the attributes for this enum.

Needed so enum-level #[PhpStormStubsElementAvailable] is honoured the same way it is for classes and interfaces.

Return Value

array