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