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