Properties

$returnByRef

$returnByRef : 

Type

$params

$params : 

Type

$attributes

$attributes : 

Type

$name

$name : 

Type

$stmts

$stmts : 

Type

Methods

makeReturnByRef()

makeReturnByRef() : $this

Make the function return by reference.

Returns

$this —

The builder instance (for fluid interface)

addParam()

addParam(\PhpParser\Node\Param|\PhpParser\Builder\Param  $param) : $this

Adds a parameter.

Parameters

\PhpParser\Node\Param|\PhpParser\Builder\Param $param

The parameter to add

Returns

$this —

The builder instance (for fluid interface)

addParams()

addParams(array  $params) : $this

Adds multiple parameters.

Parameters

array $params

The parameters to add

Returns

$this —

The builder instance (for fluid interface)

setReturnType()

setReturnType(string|\PhpParser\Node\Name|\PhpParser\Node\NullableType  $type) : $this

Sets the return type for PHP 7.

Parameters

string|\PhpParser\Node\Name|\PhpParser\Node\NullableType $type

One of array, callable, string, int, float, bool, iterable, or a class/interface name.

Returns

$this —

The builder instance (for fluid interface)

addStmt()

addStmt(\PhpParser\Node|\PhpParser\Builder  $stmt) : $this

Adds a statement.

Parameters

\PhpParser\Node|\PhpParser\Builder $stmt

The statement to add

Returns

$this —

The builder instance (for fluid interface)

addStmts()

addStmts(array  $stmts) : $this

Adds multiple statements.

Parameters

array $stmts

The statements to add

Returns

$this —

The builder instance (for fluid interface)

setDocComment()

setDocComment(\PhpParser\Comment\Doc|string  $docComment) : $this

Sets doc comment for the declaration.

Parameters

\PhpParser\Comment\Doc|string $docComment

Doc comment to set

Returns

$this —

The builder instance (for fluid interface)

__construct()

__construct(string  $name) 

Creates a function builder.

Parameters

string $name

Name of the function

getNode()

getNode() : \PhpParser\Node\Stmt\Function_

Returns the built function node.

Returns

\PhpParser\Node\Stmt\Function_

The built function node

normalizeNode()

normalizeNode(\PhpParser\Node|\PhpParser\Builder  $node) : \PhpParser\Node

Normalizes a node: Converts builder objects to nodes.

Parameters

\PhpParser\Node|\PhpParser\Builder $node

The node to normalize

Returns

\PhpParser\Node

The normalized node

normalizeName()

normalizeName(\PhpParser\Node\Name|string  $name) : \PhpParser\Node\Name

Normalizes a name: Converts plain string names to PhpParser\Node\Name.

Parameters

\PhpParser\Node\Name|string $name

The name to normalize

Returns

\PhpParser\Node\Name

The normalized name

normalizeType()

normalizeType(\PhpParser\Node\Name|string|\PhpParser\Node\NullableType  $type) : \PhpParser\Node\Name|string|\PhpParser\Node\NullableType

Normalizes a type: Converts plain-text type names into proper AST representation.

In particular, builtin types are left as strings, custom types become Names and nullables are wrapped in NullableType nodes.

Parameters

\PhpParser\Node\Name|string|\PhpParser\Node\NullableType $type

The type to normalize

Returns

\PhpParser\Node\Name|string|\PhpParser\Node\NullableType

The normalized type

normalizeValue()

normalizeValue(mixed  $value) : \PhpParser\Node\Expr

Normalizes a value: Converts nulls, booleans, integers, floats, strings and arrays into their respective nodes

Parameters

mixed $value

The value to normalize

Returns

\PhpParser\Node\Expr

The normalized value

normalizeDocComment()

normalizeDocComment(\PhpParser\Comment\Doc|string  $docComment) : \PhpParser\Comment\Doc

Normalizes a doc comment: Converts plain strings to PhpParser\Comment\Doc.

Parameters

\PhpParser\Comment\Doc|string $docComment

The doc comment to normalize

Returns

\PhpParser\Comment\Doc

The normalized doc comment

setModifier()

setModifier(integer  $modifier) 

Sets a modifier in the $this->type property.

Parameters

integer $modifier

Modifier to set