protected function parse($code, $requireSemicolons = false)
    {
        try {
            return $this->parser->parse($code);
        } catch (\PhpParser\Error $e) {
            if ($this->parseErrorIsUnclosedString($e, $code)) {
                return false;
            }

            if ($this->parseErrorIsUnterminatedComment($e, $code)) {
                return false;
            }

            if ($this->parseErrorIsTrailingComma($e, $code)) {
                return false;
            }

            if (!$this->parseErrorIsEOF($e)) {
                throw ParseErrorException::fromParseError($e);
            }

            if ($requireSemicolons) {
                return false;
            }

            try {
                // Unexpected EOF, try again with an implicit semicolon
                return $this->parser->parse($code . ';');
            } catch (\PhpParser\Error $e) {
                return false;
            }
        }
    }
protected function parse($code, $requireSemicolons = false)
    {
        try {
            return $this->parser->parse($code);
        } catch (\PhpParser\Error $e) {
            if ($this->parseErrorIsUnclosedString($e, $code)) {
                return false;
            }

            if ($this->parseErrorIsUnterminatedComment($e, $code)) {
                return false;
            }

            if ($this->parseErrorIsTrailingComma($e, $code)) {
                return false;
            }

            if (!$this->parseErrorIsEOF($e)) {
                throw ParseErrorException::fromParseError($e);
            }

            if ($requireSemicolons) {
                return false;
            }

            try {
                // Unexpected EOF, try again with an implicit semicolon
                return $this->parser->parse($code . ';');
            } catch (\PhpParser\Error $e) {
                return false;
            }
        }
    }
protected function parse ( $ code , $ requireSemicolons = false ) { try { return $ this -> parser -> parse ( $ code ) ; } catch ( \ PhpParser \ Error $ e ) { if ( $ this -> parseErrorIsUnclosedString ( $ e , $ code ) ) { return false ; } if ( $ this -> parseErrorIsUnterminatedComment ( $ e , $ code ) ) { return false ; } if ( $ this -> parseErrorIsTrailingComma ( $ e , $ code ) ) { return false ; } if ( ! $ this -> parseErrorIsEOF ( $ e ) ) { throw ParseErrorException :: fromParseError ( $ e ) ; } if ( $ requireSemicolons ) { return false ; } try { // Unexpected EOF, try again with an implicit semicolon return $ this -> parser -> parse ( $ code . ';' ) ; } catch ( \ PhpParser \ Error $ e ) { return false ; } } }
Lex and parse a block of code.

@see Parser::parse

@throws ParseErrorException for parse errors that can't be resolved by
waiting a line to see what comes next

@param string $code
@param bool   $requireSemicolons

@return array|false A set of statements, or false if incomplete
Lex and parse a block of code .