interface EnumNode (View source)

Parser-agnostic interface for enum AST nodes.

Exposes all enum properties needed for complete parsing.

Methods

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.

Details

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