2011-06-05 18:40:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2011-08-04 12:01:03 +02:00
|
|
|
* @property PHPParser_Node_Name $name Namespace/Class to alias
|
2011-08-04 12:58:12 +02:00
|
|
|
* @property string $alias Alias
|
2011-06-05 18:40:04 +02:00
|
|
|
*/
|
|
|
|
class PHPParser_Node_Stmt_UseUse extends PHPParser_Node_Stmt
|
|
|
|
{
|
2011-10-15 19:28:15 +02:00
|
|
|
/**
|
|
|
|
* Constructs an alias (use) node.
|
|
|
|
*
|
|
|
|
* @param PHPParser_Node_Name $name Namespace/Class to alias
|
2011-12-10 12:11:53 +01:00
|
|
|
* @param null|string $alias Alias
|
2011-10-15 19:28:15 +02:00
|
|
|
* @param int $line Line
|
|
|
|
* @param null|string $docComment Nearest doc comment
|
|
|
|
*/
|
2011-12-10 12:11:53 +01:00
|
|
|
public function __construct(PHPParser_Node_Name $name, $alias = null, $line = -1, $docComment = null) {
|
2011-10-15 19:28:15 +02:00
|
|
|
if (null === $alias) {
|
|
|
|
$alias = $name->getLast();
|
2011-08-04 12:58:12 +02:00
|
|
|
}
|
|
|
|
|
2011-10-15 19:28:15 +02:00
|
|
|
if ('self' == $alias || 'parent' == $alias) {
|
2011-08-04 12:58:12 +02:00
|
|
|
throw new PHPParser_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-08-04 12:58:12 +02:00
|
|
|
));
|
|
|
|
}
|
2011-10-15 19:28:15 +02:00
|
|
|
|
|
|
|
parent::__construct(
|
|
|
|
array(
|
|
|
|
'name' => $name,
|
|
|
|
'alias' => $alias,
|
|
|
|
),
|
|
|
|
$line, $docComment
|
|
|
|
);
|
2011-08-04 12:58:12 +02:00
|
|
|
}
|
2011-06-05 18:40:04 +02:00
|
|
|
}
|