Mercurial > hg > isophonics-drupal-site
annotate vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 5fb285c0d0e3 |
children |
rev | line source |
---|---|
Chris@13 | 1 <?php declare(strict_types=1); |
Chris@0 | 2 |
Chris@0 | 3 namespace PhpParser\Builder; |
Chris@0 | 4 |
Chris@0 | 5 use PhpParser; |
Chris@13 | 6 use PhpParser\BuilderHelpers; |
Chris@0 | 7 use PhpParser\Node; |
Chris@0 | 8 use PhpParser\Node\Stmt; |
Chris@0 | 9 |
Chris@0 | 10 class Function_ extends FunctionLike |
Chris@0 | 11 { |
Chris@0 | 12 protected $name; |
Chris@13 | 13 protected $stmts = []; |
Chris@0 | 14 |
Chris@0 | 15 /** |
Chris@0 | 16 * Creates a function builder. |
Chris@0 | 17 * |
Chris@0 | 18 * @param string $name Name of the function |
Chris@0 | 19 */ |
Chris@13 | 20 public function __construct(string $name) { |
Chris@0 | 21 $this->name = $name; |
Chris@0 | 22 } |
Chris@0 | 23 |
Chris@0 | 24 /** |
Chris@0 | 25 * Adds a statement. |
Chris@0 | 26 * |
Chris@0 | 27 * @param Node|PhpParser\Builder $stmt The statement to add |
Chris@0 | 28 * |
Chris@0 | 29 * @return $this The builder instance (for fluid interface) |
Chris@0 | 30 */ |
Chris@0 | 31 public function addStmt($stmt) { |
Chris@13 | 32 $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); |
Chris@0 | 33 |
Chris@0 | 34 return $this; |
Chris@0 | 35 } |
Chris@0 | 36 |
Chris@0 | 37 /** |
Chris@0 | 38 * Returns the built function node. |
Chris@0 | 39 * |
Chris@0 | 40 * @return Stmt\Function_ The built function node |
Chris@0 | 41 */ |
Chris@13 | 42 public function getNode() : Node { |
Chris@13 | 43 return new Stmt\Function_($this->name, [ |
Chris@0 | 44 'byRef' => $this->returnByRef, |
Chris@0 | 45 'params' => $this->params, |
Chris@0 | 46 'returnType' => $this->returnType, |
Chris@0 | 47 'stmts' => $this->stmts, |
Chris@13 | 48 ], $this->attributes); |
Chris@0 | 49 } |
Chris@0 | 50 } |