protected function parseUseDeclaration()
{
$fragments = $this->parseQualifiedNameRaw();
$this->consumeComments();
// Add leading backslash, because aliases must be full qualified
// http://php.net/manual/en/language.namespaces.importing.php
if ($fragments[0] !== '\\') {
array_unshift($fragments, '\\');
}
if ($this->tokenizer->peek() === Tokens::T_AS) {
$this->consumeToken(Tokens::T_AS);
$this->consumeComments();
$image = $this->consumeToken(Tokens::T_STRING)->image;
$this->consumeComments();
} else {
$image = end($fragments);
}
// Add mapping between image and qualified name to symbol table
$this->useSymbolTable->add($image, join('', $fragments));
// Check for a following use declaration
if ($this->tokenizer->peek() === Tokens::T_COMMA) {
// Consume comma token and comments
$this->consumeToken(Tokens::T_COMMA);
$this->consumeComments();
$this->parseUseDeclaration();
}
}