1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-13 18:07:32 +01:00
PHP-Parser/lib/PhpParser/Node/Stmt/UseUse.php

53 lines
1.6 KiB
PHP
Raw Normal View History

2017-08-18 22:57:27 +02:00
<?php declare(strict_types=1);
2011-06-05 18:40:04 +02:00
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\Identifier;
class UseUse extends Node\Stmt
2011-06-05 18:40:04 +02:00
{
2015-06-13 11:27:38 +02:00
/** @var int One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */
public $type;
/** @var Node\Name Namespace, class, function or constant to alias */
public $name;
/** @var Identifier|null Alias */
public $alias;
2011-10-15 19:28:15 +02:00
/**
* Constructs an alias (use) node.
*
* @param Node\Name $name Namespace/Class to alias
* @param null|string|Identifier $alias Alias
* @param int $type Type of the use element (for mixed group use only)
* @param array $attributes Additional attributes
2011-10-15 19:28:15 +02:00
*/
public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) {
2015-05-02 22:17:34 +02:00
parent::__construct($attributes);
2015-06-13 11:27:38 +02:00
$this->type = $type;
$this->name = $name;
$this->alias = \is_string($alias) ? new Identifier($alias) : $alias;
}
2017-04-28 21:40:59 +02:00
public function getSubNodeNames() : array {
return ['type', 'name', 'alias'];
}
/**
* Get alias. If not explicitly given this is the last component of the used name.
*
* @return Identifier
*/
2017-04-28 21:40:59 +02:00
public function getAlias() : Identifier {
if (null !== $this->alias) {
return $this->alias;
}
return new Identifier($this->name->getLast());
}
function getType() : string {
return 'Stmt_UseUse';
}
}