class NikicGlobalConstantNode implements ConstantDefinitionNode (View source)

Adapter for nikic/php-parser Const_ nodes representing global const declarations.

Wraps individual constants from const statements (e.g., const A = 1, B = 2). Provides parser-agnostic access to constant properties.

Traits

Resolves PhpParser expression nodes to plain PHP scalar values.

Methods

__construct(Const_ $const, Doc|null $docComment = null)

No description

string
getName()

Get the constant name.

mixed
getValue()

Get the constant value as a plain PHP scalar.

getDocComment()

Get the doc comment node attached to this constant definition, or null if none.

string
getNamespace()

Get the namespace where this constant is defined.

void
setNamespace(string $namespace)

Set the namespace for this constant.

Details

__construct(Const_ $const, Doc|null $docComment = null)

No description

Parameters

Const_ $const

The individual constant node.

Doc|null $docComment

The doc comment, which nikic attaches to the wrapping Const_ statement rather than to the individual constant. A single doc comment is shared by all constants declared together (e.g. const A = 1, B = 2).

string getName()

Get the constant name.

Return Value

string

mixed getValue()

Get the constant value as a plain PHP scalar.

Returns null for complex expressions that cannot be statically evaluated.

Return Value

mixed

DocCommentNode|null getDocComment()

Get the doc comment node attached to this constant definition, or null if none.

Return Value

DocCommentNode|null

string getNamespace()

Get the namespace where this constant is defined.

Return Value

string

void setNamespace(string $namespace)

Set the namespace for this constant.

Parameters

string $namespace

Return Value

void