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