annotate vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.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 Function_ extends FunctionLike
Chris@0 10 {
Chris@0 11 protected $name;
Chris@0 12 protected $stmts = array();
Chris@0 13
Chris@0 14 /**
Chris@0 15 * Creates a function builder.
Chris@0 16 *
Chris@0 17 * @param string $name Name of the function
Chris@0 18 */
Chris@0 19 public function __construct($name) {
Chris@0 20 $this->name = $name;
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 function node.
Chris@0 38 *
Chris@0 39 * @return Stmt\Function_ The built function node
Chris@0 40 */
Chris@0 41 public function getNode() {
Chris@0 42 return new Stmt\Function_($this->name, array(
Chris@0 43 'byRef' => $this->returnByRef,
Chris@0 44 'params' => $this->params,
Chris@0 45 'returnType' => $this->returnType,
Chris@0 46 'stmts' => $this->stmts,
Chris@0 47 ), $this->attributes);
Chris@0 48 }
Chris@0 49 }