1 <?php declare(strict_types=1);
3 namespace PhpParser\Node\Stmt;
6 use PhpParser\Node\Identifier;
8 class UseUse extends Node\Stmt
10 /** @var int One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */
12 /** @var Node\Name Namespace, class, function or constant to alias */
14 /** @var Identifier|null Alias */
18 * Constructs an alias (use) node.
20 * @param Node\Name $name Namespace/Class to alias
21 * @param null|string|Identifier $alias Alias
22 * @param int $type Type of the use element (for mixed group use only)
23 * @param array $attributes Additional attributes
25 public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) {
26 parent::__construct($attributes);
29 $this->alias = \is_string($alias) ? new Identifier($alias) : $alias;
32 public function getSubNodeNames() : array {
33 return ['type', 'name', 'alias'];
37 * Get alias. If not explicitly given this is the last component of the used name.
41 public function getAlias() : Identifier {
42 if (null !== $this->alias) {
46 return new Identifier($this->name->getLast());
49 public function getType() : string {