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