class Function_
Same name in this branch
- 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php \PhpParser\Node\Scalar\MagicConst\Function_
- 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php \PhpParser\Node\Stmt\Function_
- 11.1.x vendor/mck89/peast/lib/Peast/Syntax/Node/Function_.php \Peast\Syntax\Node\Function_
Hierarchy
- class \PhpParser\Builder\Declaration implements \PhpParser\Builder
- class \PhpParser\Builder\FunctionLike extends \PhpParser\Builder\Declaration
- class \PhpParser\Builder\Function_ extends \PhpParser\Builder\FunctionLike
- class \PhpParser\Builder\FunctionLike extends \PhpParser\Builder\Declaration
Expanded class hierarchy of Function_
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ Function_.php, line 10
Namespace
PhpParser\BuilderView source
class Function_ extends FunctionLike {
protected string $name;
/** @var list<Stmt> */
protected array $stmts = [];
/** @var list<Node\AttributeGroup> */
protected array $attributeGroups = [];
/**
* Creates a function builder.
*
* @param string $name Name of the function
*/
public function __construct(string $name) {
$this->name = $name;
}
/**
* Adds a statement.
*
* @param Node|PhpParser\Builder $stmt The statement to add
*
* @return $this The builder instance (for fluid interface)
*/
public function addStmt($stmt) {
$this->stmts[] = BuilderHelpers::normalizeStmt($stmt);
return $this;
}
/**
* Adds an attribute group.
*
* @param Node\Attribute|Node\AttributeGroup $attribute
*
* @return $this The builder instance (for fluid interface)
*/
public function addAttribute($attribute) {
$this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute);
return $this;
}
/**
* Returns the built function node.
*
* @return Stmt\Function_ The built function node
*/
public function getNode() : Node {
return new Stmt\Function_($this->name, [
'byRef' => $this->returnByRef,
'params' => $this->params,
'returnType' => $this->returnType,
'stmts' => $this->stmts,
'attrGroups' => $this->attributeGroups,
], $this->attributes);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
Declaration::$attributes | protected | property | @var array<string, mixed> | |
Declaration::addStmts | public | function | Adds multiple statements. | |
Declaration::setDocComment | public | function | Sets doc comment for the declaration. | |
FunctionLike::$params | protected | property | @var Node\Param[] | |
FunctionLike::$returnByRef | protected | property | ||
FunctionLike::$returnType | protected | property | @var Node\Identifier|Node\Name|Node\ComplexType|null | |
FunctionLike::addParam | public | function | Adds a parameter. | |
FunctionLike::addParams | public | function | Adds multiple parameters. | |
FunctionLike::makeReturnByRef | public | function | Make the function return by reference. | |
FunctionLike::setReturnType | public | function | Sets the return type for PHP 7. | |
Function_::$attributeGroups | protected | property | @var list<Node\AttributeGroup> | |
Function_::$name | protected | property | ||
Function_::$stmts | protected | property | @var list<Stmt> | |
Function_::addAttribute | public | function | Adds an attribute group. | |
Function_::addStmt | public | function | Adds a statement. | Overrides Declaration::addStmt |
Function_::getNode | public | function | Returns the built function node. | Overrides Builder::getNode |
Function_::__construct | public | function | Creates a function builder. |