interface FunctionNode (View source)

Parser-agnostic interface for function AST nodes.

Implementations wrap specific parser library nodes (e.g., nikic/php-parser).

Methods

string
getName()

Get the function name.

array
getParameters()

Get the function parameters.

TypeNode|null
getReturnType()

Get the return type node, or null if no return type.

getDocComment()

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

void
setNamespace(string $namespace)

Set the namespace for this function.

string
getNamespace()

Get the namespace for this function.

array
getAttributes()

Get the function attributes (PHP 8.0+).

void
setImports(array $imports)

Set the imports (use statements) for this function's file context.

array
getImports()

Get the imports (use statements) for this function's file context.

Details

string getName()

Get the function name.

Return Value

string

array getParameters()

Get the function parameters.

Return Value

array

TypeNode|null getReturnType()

Get the return type node, or null if no return type.

Return Value

TypeNode|null

DocCommentNode|null getDocComment()

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

Return Value

DocCommentNode|null

void setNamespace(string $namespace)

Set the namespace for this function.

Parameters

string $namespace

Return Value

void

string getNamespace()

Get the namespace for this function.

Return Value

string

array getAttributes()

Get the function attributes (PHP 8.0+).

Return Value

array

void setImports(array $imports)

Set the imports (use statements) for this function's file context.

Maps alias names to fully qualified class names.

Parameters

array $imports

Map of ['Alias' => 'Fully\Qualified\Name']

Return Value

void

array getImports()

Get the imports (use statements) for this function's file context.

Return Value

array

Map of ['Alias' => 'Fully\Qualified\Name']