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