PDepend\Source\Language\PHP\AbstractPHPParser::parseHeredoc PHP Method

parseHeredoc() protected method

Parses a here- or nowdoc string instance.
Since: 0.9.12
protected parseHeredoc ( ) : PDepend\Source\AST\ASTHeredoc
return PDepend\Source\AST\ASTHeredoc
    protected function parseHeredoc()
    {
        $this->tokenStack->push();
        $this->consumeToken(Tokens::T_START_HEREDOC);
        $heredoc = $this->builder->buildAstHeredoc();
        $this->parseStringExpressions($heredoc, Tokens::T_END_HEREDOC);
        $token = $this->consumeToken(Tokens::T_END_HEREDOC);
        $heredoc->setDelimiter($token->image);
        return $this->setNodePositionsAndReturn($heredoc);
    }

Usage Example

Beispiel #1
0
 /**
  * Implements some quirks and hacks to support php here- and now-doc for
  * PHP 5.2.x versions :/
  *
  * @return \PDepend\Source\AST\ASTHeredoc
  * @since 1.0.0
  */
 protected function parseHeredoc()
 {
     $heredoc = parent::parseHeredoc();
     if (version_compare(phpversion(), "5.3.0alpha") >= 0) {
         return $heredoc;
     }
     // Consume dangling semicolon
     $this->tokenizer->next();
     $token = $this->tokenizer->next();
     preg_match('(/\\*(\'|")\\*/)', $token->image, $match);
     return $heredoc;
 }
AbstractPHPParser