| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace PhpParser\Node; |
| 4: | |
| 5: | use PhpParser\Node; |
| 6: | use PhpParser\NodeAbstract; |
| 7: | use PhpParser\Node\Stmt\Use_; |
| 8: | |
| 9: | class UseItem extends NodeAbstract { |
| 10: | |
| 11: | |
| 12: | |
| 13: | public int $type; |
| 14: | |
| 15: | public Name $name; |
| 16: | |
| 17: | public ?Identifier $alias; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) { |
| 28: | $this->attributes = $attributes; |
| 29: | $this->type = $type; |
| 30: | $this->name = $name; |
| 31: | $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; |
| 32: | } |
| 33: | |
| 34: | public function getSubNodeNames(): array { |
| 35: | return ['type', 'name', 'alias']; |
| 36: | } |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public function getAlias(): Identifier { |
| 42: | if (null !== $this->alias) { |
| 43: | return $this->alias; |
| 44: | } |
| 45: | |
| 46: | return new Identifier($this->name->getLast()); |
| 47: | } |
| 48: | |
| 49: | public function getType(): string { |
| 50: | return 'UseItem'; |
| 51: | } |
| 52: | } |
| 53: | |
| 54: | |
| 55: | class_alias(UseItem::class, Stmt\UseUse::class); |
| 56: | |