1: | <?php declare(strict_types=1); |
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: | |
11: | public $byRef; |
12: | |
13: | public $name; |
14: | |
15: | public $params; |
16: | |
17: | public $returnType; |
18: | |
19: | public $stmts; |
20: | |
21: | public $attrGroups; |
22: | |
23: | |
24: | public $namespacedName; |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | public function __construct($name, array $subNodes = [], array $attributes = []) { |
39: | $this->attributes = $attributes; |
40: | $this->byRef = $subNodes['byRef'] ?? false; |
41: | $this->name = \is_string($name) ? new Node\Identifier($name) : $name; |
42: | $this->params = $subNodes['params'] ?? []; |
43: | $returnType = $subNodes['returnType'] ?? null; |
44: | $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; |
45: | $this->stmts = $subNodes['stmts'] ?? []; |
46: | $this->attrGroups = $subNodes['attrGroups'] ?? []; |
47: | } |
48: | |
49: | public function getSubNodeNames() : array { |
50: | return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; |
51: | } |
52: | |
53: | public function returnsByRef() : bool { |
54: | return $this->byRef; |
55: | } |
56: | |
57: | public function getParams() : array { |
58: | return $this->params; |
59: | } |
60: | |
61: | public function getReturnType() { |
62: | return $this->returnType; |
63: | } |
64: | |
65: | public function getAttrGroups() : array { |
66: | return $this->attrGroups; |
67: | } |
68: | |
69: | |
70: | public function getStmts() : array { |
71: | return $this->stmts; |
72: | } |
73: | |
74: | public function getType() : string { |
75: | return 'Stmt_Function'; |
76: | } |
77: | } |
78: | |