/** * This method parses a {@link \PDepend\Source\AST\ASTParentReference} node. * * @param \PDepend\Source\Tokenizer\Token $token The "self" keyword token. * @return \PDepend\Source\AST\ASTNode * @throws \PDepend\Source\Parser\ParserException * @throws \PDepend\Source\Parser\InvalidStateException * @since 0.9.6 */ private function parseParentReference(Token $token) { if ($this->classOrInterface === null) { throw new InvalidStateException($token->startLine, (string) $this->compilationUnit, 'The keyword "parent" was used as type hint but the parameter ' . 'declaration is not in a class scope.'); } if ($this->classOrInterface instanceof ASTTrait) { $classReference = $this->builder->buildAstClassReference('__PDepend_TraitRuntimeReference'); } else { $classReference = $this->classOrInterface->getParentClassReference(); } if ($classReference === null) { throw new InvalidStateException($token->startLine, (string) $this->compilationUnit, 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; }