3 namespace PhpParser\Builder;
7 use PhpParser\Node\Stmt;
9 class Function_ extends FunctionLike
12 protected $stmts = array();
15 * Creates a function builder.
17 * @param string $name Name of the function
19 public function __construct($name) {
26 * @param Node|PhpParser\Builder $stmt The statement to add
28 * @return $this The builder instance (for fluid interface)
30 public function addStmt($stmt) {
31 $this->stmts[] = $this->normalizeNode($stmt);
37 * Returns the built function node.
39 * @return Stmt\Function_ The built function node
41 public function getNode() {
42 return new Stmt\Function_($this->name, array(
43 'byRef' => $this->returnByRef,
44 'params' => $this->params,
45 'returnType' => $this->returnType,
46 'stmts' => $this->stmts,
47 ), $this->attributes);