예제 #1
0
파일: Parser.php 프로젝트: rouffj/pdepend
 /**
  * This method parses a {@link PHP_Depend_Code_ASTParentReference} node.
  *
  * @param PHP_Depend_Token $token The "self" keyword token.
  *
  * @return PHP_Depend_Code_ASTNode
  * @throws PHP_Depend_Parser_Exception When an error occured during the
  *         parsing process.
  * @throws PHP_Depend_Parser_InvalidStateException When the keyword parent
  *         was used outside of a class or interface scope.
  * @since 0.9.6
  */
 private function _parseParentReference(PHP_Depend_Token $token)
 {
     if ($this->_classOrInterface === null) {
         throw new PHP_Depend_Parser_InvalidStateException($token->startLine, (string) $this->_sourceFile, 'The keyword "parent" was used as type hint but the parameter ' . 'declaration is not in a class scope.');
     }
     $classReference = $this->_classOrInterface->getParentClassReference();
     if ($classReference === null) {
         throw new PHP_Depend_Parser_InvalidStateException($token->startLine, (string) $this->_sourceFile, sprintf('The keyword "parent" was used as type hint but the ' . 'class "%s" does not declare a parent.', $this->_classOrInterface->getName()));
     }
     $ref = $this->builder->buildASTParentReference($classReference);
     $ref->configureLinesAndColumns($token->startLine, $token->endLine, $token->startColumn, $token->endColumn);
     return $ref;
 }
예제 #2
0
 /**
  * This method parses a {@link PHP_Depend_Code_ASTParentReference} node.
  *
  * @param PHP_Depend_Token $token The "self" keyword token.
  *
  * @return PHP_Depend_Code_ASTNode
  * @throws PHP_Depend_Parser_Exception When an error occured during the
  *         parsing process.
  * @throws PHP_Depend_Parser_InvalidStateException When the keyword parent
  *         was used outside of a class or interface scope.
  * @since 0.9.6
  */
 private function _parseParentReference(PHP_Depend_Token $token)
 {
     if ($this->_classOrInterface === null) {
         throw new PHP_Depend_Parser_InvalidStateException($token->startLine, (string) $this->_sourceFile, 'The keyword "parent" was used outside of a class/method scope.');
     }
     $classReference = $this->_classOrInterface->getParentClassReference();
     if ($classReference === null) {
         throw new PHP_Depend_Parser_InvalidStateException($token->startLine, (string) $this->_sourceFile, sprintf('The keyword "parent" was used but the ' . 'class "%s" does not declare a parent.', $this->_classOrInterface->getName()));
     }
     return $this->_builder->buildASTParentReference($classReference);
 }