PhpParser\Lexer::handleHaltCompiler PHP Method

handleHaltCompiler() public method

Handles __halt_compiler() by returning the text after it.
public handleHaltCompiler ( ) : string
return string Remaining text
    public function handleHaltCompiler()
    {
        // text after T_HALT_COMPILER, still including ();
        $textAfter = substr($this->code, $this->filePos);
        // ensure that it is followed by ();
        // this simplifies the situation, by not allowing any comments
        // in between of the tokens.
        if (!preg_match('~^\\s*\\(\\s*\\)\\s*(?:;|\\?>\\r?\\n?)~', $textAfter, $matches)) {
            throw new Error('__HALT_COMPILER must be followed by "();"');
        }
        // prevent the lexer from returning any further tokens
        $this->pos = count($this->tokens);
        // return with (); removed
        return (string) substr($textAfter, strlen($matches[0]));
        // (string) converts false to ''
    }