Mercurial > hg > isophonics-drupal-site
annotate vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 5fb285c0d0e3 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace PhpParser\Builder; |
Chris@0 | 4 |
Chris@0 | 5 use PhpParser; |
Chris@0 | 6 use PhpParser\Node; |
Chris@0 | 7 use PhpParser\Node\Stmt; |
Chris@0 | 8 |
Chris@0 | 9 class Namespace_ extends Declaration |
Chris@0 | 10 { |
Chris@0 | 11 private $name; |
Chris@0 | 12 private $stmts = array(); |
Chris@0 | 13 |
Chris@0 | 14 /** |
Chris@0 | 15 * Creates a namespace builder. |
Chris@0 | 16 * |
Chris@0 | 17 * @param Node\Name|string|null $name Name of the namespace |
Chris@0 | 18 */ |
Chris@0 | 19 public function __construct($name) { |
Chris@0 | 20 $this->name = null !== $name ? $this->normalizeName($name) : null; |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * Adds a statement. |
Chris@0 | 25 * |
Chris@0 | 26 * @param Node|PhpParser\Builder $stmt The statement to add |
Chris@0 | 27 * |
Chris@0 | 28 * @return $this The builder instance (for fluid interface) |
Chris@0 | 29 */ |
Chris@0 | 30 public function addStmt($stmt) { |
Chris@0 | 31 $this->stmts[] = $this->normalizeNode($stmt); |
Chris@0 | 32 |
Chris@0 | 33 return $this; |
Chris@0 | 34 } |
Chris@0 | 35 |
Chris@0 | 36 /** |
Chris@0 | 37 * Returns the built node. |
Chris@0 | 38 * |
Chris@0 | 39 * @return Node The built node |
Chris@0 | 40 */ |
Chris@0 | 41 public function getNode() { |
Chris@0 | 42 return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes); |
Chris@0 | 43 } |
Chris@0 | 44 } |