Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Builder / Function_.php
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Builder;
4
5 use PhpParser;
6 use PhpParser\BuilderHelpers;
7 use PhpParser\Node;
8 use PhpParser\Node\Stmt;
9
10 class Function_ extends FunctionLike
11 {
12     protected $name;
13     protected $stmts = [];
14
15     /**
16      * Creates a function builder.
17      *
18      * @param string $name Name of the function
19      */
20     public function __construct(string $name) {
21         $this->name = $name;
22     }
23
24     /**
25      * Adds a statement.
26      *
27      * @param Node|PhpParser\Builder $stmt The statement to add
28      *
29      * @return $this The builder instance (for fluid interface)
30      */
31     public function addStmt($stmt) {
32         $this->stmts[] = BuilderHelpers::normalizeStmt($stmt);
33
34         return $this;
35     }
36
37     /**
38      * Returns the built function node.
39      *
40      * @return Stmt\Function_ The built function node
41      */
42     public function getNode() : Node {
43         return new Stmt\Function_($this->name, [
44             'byRef'      => $this->returnByRef,
45             'params'     => $this->params,
46             'returnType' => $this->returnType,
47             'stmts'      => $this->stmts,
48         ], $this->attributes);
49     }
50 }