1 <?php declare(strict_types=1);
3 namespace PhpParser\Builder;
6 use PhpParser\BuilderHelpers;
8 use PhpParser\Node\Stmt;
10 class Namespace_ extends Declaration
16 * Creates a namespace builder.
18 * @param Node\Name|string|null $name Name of the namespace
20 public function __construct($name) {
21 $this->name = null !== $name ? BuilderHelpers::normalizeName($name) : null;
27 * @param Node|PhpParser\Builder $stmt The statement to add
29 * @return $this The builder instance (for fluid interface)
31 public function addStmt($stmt) {
32 $this->stmts[] = BuilderHelpers::normalizeStmt($stmt);
38 * Returns the built node.
40 * @return Node The built node
42 public function getNode() : Node {
43 return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes);