1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-11 17:09:41 +01:00
PHP-Parser/lib/PhpParser/Node/Stmt/UseUse.php

43 lines
1.1 KiB
PHP
Raw Normal View History

2011-06-05 18:40:04 +02:00
<?php
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Error;
class UseUse extends Node\Stmt
2011-06-05 18:40:04 +02:00
{
/** @var Node\Name Namespace, class, function or constant to alias */
public $name;
/** @var string 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 $alias Alias
* @param array $attributes Additional attributes
2011-10-15 19:28:15 +02:00
*/
public function __construct(Node\Name $name, $alias = null, array $attributes = array()) {
2011-10-15 19:28:15 +02:00
if (null === $alias) {
$alias = $name->getLast();
}
if ('self' == strtolower($alias) || 'parent' == strtolower($alias)) {
throw new Error(sprintf(
'Cannot use %s as %s because \'%2$s\' is a special class name',
2011-10-15 19:28:15 +02:00
$name, $alias
));
}
2011-10-15 19:28:15 +02:00
parent::__construct(null, $attributes);
$this->name = $name;
$this->alias = $alias;
}
public function getSubNodeNames() {
return array('name', 'alias');
}
}