Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Builder / Namespace_.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 Namespace_ extends Declaration
11 {
12     private $name;
13     private $stmts = [];
14
15     /**
16      * Creates a namespace builder.
17      *
18      * @param Node\Name|string|null $name Name of the namespace
19      */
20     public function __construct($name) {
21         $this->name = null !== $name ? BuilderHelpers::normalizeName($name) : null;
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 node.
39      *
40      * @return Node The built node
41      */
42     public function getNode() : Node {
43         return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes);
44     }
45 }