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 ArrowFunction extends Expr implements FunctionLike |
10: | { |
11: | |
12: | public $static; |
13: | |
14: | |
15: | public $byRef; |
16: | |
17: | |
18: | public $params = []; |
19: | |
20: | |
21: | public $returnType; |
22: | |
23: | |
24: | public $expr; |
25: | |
26: | public $attrGroups; |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | public function __construct(array $subNodes = [], array $attributes = []) { |
39: | $this->attributes = $attributes; |
40: | $this->static = $subNodes['static'] ?? false; |
41: | $this->byRef = $subNodes['byRef'] ?? false; |
42: | $this->params = $subNodes['params'] ?? []; |
43: | $returnType = $subNodes['returnType'] ?? null; |
44: | $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; |
45: | $this->expr = $subNodes['expr']; |
46: | $this->attrGroups = $subNodes['attrGroups'] ?? []; |
47: | } |
48: | |
49: | public function getSubNodeNames() : array { |
50: | return ['attrGroups', 'static', 'byRef', 'params', 'returnType', 'expr']; |
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: | |
71: | |
72: | public function getStmts() : array { |
73: | return [new Node\Stmt\Return_($this->expr)]; |
74: | } |
75: | |
76: | public function getType() : string { |
77: | return 'Expr_ArrowFunction'; |
78: | } |
79: | } |
80: | |