Esempio n. 1
0
 /**
  * This method will parse a formal parameter that has the keyword self as
  * parameter type hint.
  *
  * <code>
  * class Foo
  * {
  *     //                   -------
  *     public function test(self $o) {}
  *     //                   -------
  * }
  * </code>
  *
  * @return \PDepend\Source\AST\ASTFormalParameter
  * @since  0.9.6
  */
 private function parseFormalParameterAndSelfTypeHint()
 {
     $token = $this->consumeToken(Tokens::T_SELF);
     $self = $this->builder->buildAstSelfReference($this->classOrInterface);
     $self->configureLinesAndColumns($token->startLine, $token->endLine, $token->startColumn, $token->endColumn);
     $parameter = $this->parseFormalParameterOrByReference();
     $parameter->addChild($self);
     return $parameter;
 }
Esempio n. 2
0
 /**
  * This method parses a {@link \PDepend\Source\AST\ASTSelfReference} node.
  *
  * @param  \PDepend\Source\Tokenizer\Token $token The "self" keyword token.
  * @return \PDepend\Source\AST\ASTSelfReference
  * @throws \PDepend\Source\Parser\ParserException
  * @throws \PDepend\Source\Parser\InvalidStateException
  * @since  0.9.6
  */
 protected function parseSelfReference(Token $token)
 {
     if ($this->classOrInterface === null) {
         throw new InvalidStateException($token->startLine, (string) $this->compilationUnit, 'The keyword "self" was used outside of a class/method scope.');
     }
     $ref = $this->builder->buildAstSelfReference($this->classOrInterface);
     $ref->configureLinesAndColumns($token->startLine, $token->endLine, $token->startColumn, $token->endColumn);
     return $ref;
 }