Ejemplo n.º 1
0
 /**
  * This method parses a single use declaration and adds a mapping between
  * short name and full qualified name to the use symbol table.
  *
  * @return void
  * @since 0.9.5
  */
 private 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() === self::T_AS) {
         $this->consumeToken(self::T_AS);
         $this->consumeComments();
         $image = $this->consumeToken(self::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() === self::T_COMMA) {
         // Consume comma token and comments
         $this->consumeToken(self::T_COMMA);
         $this->consumeComments();
         $this->_parseUseDeclaration();
     }
 }