1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpParser\Node\Stmt; |
4
|
|
|
|
5
|
|
|
use PhpParser\Node; |
6
|
|
|
use PhpParser\Node\FunctionLike; |
7
|
|
|
|
8
|
|
|
class Function_ extends Node\Stmt implements FunctionLike |
9
|
|
|
{ |
10
|
|
|
/** @var bool Whether function returns by reference */ |
11
|
|
|
public $byRef; |
12
|
|
|
/** @var string Name */ |
13
|
|
|
public $name; |
14
|
|
|
/** @var Node\Param[] Parameters */ |
15
|
|
|
public $params; |
16
|
|
|
/** @var null|string|Node\Name Return type */ |
17
|
|
|
public $returnType; |
18
|
|
|
/** @var Node[] Statements */ |
19
|
|
|
public $stmts; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Constructs a function node. |
23
|
|
|
* |
24
|
|
|
* @param string $name Name |
25
|
|
|
* @param array $subNodes Array of the following optional subnodes: |
26
|
|
|
* 'byRef' => false : Whether to return by reference |
27
|
|
|
* 'params' => array(): Parameters |
28
|
|
|
* 'returnType' => null : Return type |
29
|
|
|
* 'stmts' => array(): Statements |
30
|
|
|
* @param array $attributes Additional attributes |
31
|
|
|
*/ |
32
|
|
|
public function __construct($name, array $subNodes = array(), array $attributes = array()) { |
33
|
|
|
parent::__construct($attributes); |
34
|
|
|
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; |
35
|
|
|
$this->name = $name; |
36
|
|
|
$this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); |
37
|
|
|
$this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; |
38
|
|
|
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getSubNodeNames() { |
42
|
|
|
return array('byRef', 'name', 'params', 'returnType', 'stmts'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function returnsByRef() { |
46
|
|
|
return $this->byRef; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getParams() { |
50
|
|
|
return $this->params; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getReturnType() { |
54
|
|
|
return $this->returnType; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getStmts() { |
58
|
|
|
return $this->stmts; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|