annotate vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/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\Node\Stmt;
Chris@0 4
Chris@0 5 use PhpParser\Node;
Chris@0 6 use PhpParser\Node\FunctionLike;
Chris@0 7
Chris@13 8 /**
Chris@13 9 * @property Node\Name $namespacedName Namespaced name (if using NameResolver)
Chris@13 10 */
Chris@0 11 class Function_ extends Node\Stmt implements FunctionLike
Chris@0 12 {
Chris@0 13 /** @var bool Whether function returns by reference */
Chris@0 14 public $byRef;
Chris@13 15 /** @var Node\Identifier Name */
Chris@0 16 public $name;
Chris@0 17 /** @var Node\Param[] Parameters */
Chris@0 18 public $params;
Chris@13 19 /** @var null|Node\Identifier|Node\Name|Node\NullableType Return type */
Chris@0 20 public $returnType;
Chris@13 21 /** @var Node\Stmt[] Statements */
Chris@0 22 public $stmts;
Chris@0 23
Chris@0 24 /**
Chris@0 25 * Constructs a function node.
Chris@0 26 *
Chris@13 27 * @param string|Node\Identifier $name Name
Chris@0 28 * @param array $subNodes Array of the following optional subnodes:
Chris@0 29 * 'byRef' => false : Whether to return by reference
Chris@0 30 * 'params' => array(): Parameters
Chris@0 31 * 'returnType' => null : Return type
Chris@0 32 * 'stmts' => array(): Statements
Chris@0 33 * @param array $attributes Additional attributes
Chris@0 34 */
Chris@13 35 public function __construct($name, array $subNodes = [], array $attributes = []) {
Chris@0 36 parent::__construct($attributes);
Chris@13 37 $this->byRef = $subNodes['byRef'] ?? false;
Chris@13 38 $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
Chris@13 39 $this->params = $subNodes['params'] ?? [];
Chris@13 40 $returnType = $subNodes['returnType'] ?? null;
Chris@13 41 $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
Chris@13 42 $this->stmts = $subNodes['stmts'] ?? [];
Chris@0 43 }
Chris@0 44
Chris@13 45 public function getSubNodeNames() : array {
Chris@13 46 return ['byRef', 'name', 'params', 'returnType', 'stmts'];
Chris@0 47 }
Chris@0 48
Chris@13 49 public function returnsByRef() : bool {
Chris@0 50 return $this->byRef;
Chris@0 51 }
Chris@0 52
Chris@13 53 public function getParams() : array {
Chris@0 54 return $this->params;
Chris@0 55 }
Chris@0 56
Chris@0 57 public function getReturnType() {
Chris@0 58 return $this->returnType;
Chris@0 59 }
Chris@0 60
Chris@13 61 /** @return Node\Stmt[] */
Chris@13 62 public function getStmts() : array {
Chris@0 63 return $this->stmts;
Chris@0 64 }
Chris@13 65
Chris@13 66 public function getType() : string {
Chris@13 67 return 'Stmt_Function';
Chris@13 68 }
Chris@0 69 }