src/Jit/Parser.php
protected function _classNode()
    {
        if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
            $this->_states['body'] .= 'class';
            return;
        }

        $this->_codeNode();
        $token = $this->_stream->current(true);
        $body = $token[1];
        $body .= $this->_stream->skipWhitespaces();
        $body .= $name = $this->_stream->current();
        if ($name !== '{') {
            $body .= $this->_stream->next(['{', T_EXTENDS, T_IMPLEMENTS]);
        } else {
            $name = '';
        }
        $token = $this->_stream->current(true);
        $extends = '';
        $implements = '';
        if ($token[0] === T_EXTENDS) {
            $body .= $this->_stream->skipWhitespaces();
            $body .= $extends = $this->_stream->skipWhile([T_STRING, T_NS_SEPARATOR]);
            $body .= $this->_stream->current();
            if ($this->_stream->current() !== '{') {
                $body .= $this->_stream->next('{');
            }
        } elseif ($token[0] === T_IMPLEMENTS) {
            $body .= $implements = $this->_stream->next('{');
            $implements = substr($implements, 0, -1);
        }
        $node = new BlockDef($body, 'class');
        $node->name = $name;
        $node->extends = $this->_normalizeClass($extends);
        $node->implements = $this->_normalizeImplements($implements);

        $this->_states['body'] .= $body;
        return $this->_states['current'] = $this->_contextualize($node);
    }
protected function _classNode()
    {
        if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
            $this->_states['body'] .= 'class';
            return;
        }

        $this->_codeNode();
        $token = $this->_stream->current(true);
        $body = $token[1];
        $body .= $this->_stream->skipWhitespaces();
        $body .= $name = $this->_stream->current();
        if ($name !== '{') {
            $body .= $this->_stream->next(['{', T_EXTENDS, T_IMPLEMENTS]);
        } else {
            $name = '';
        }
        $token = $this->_stream->current(true);
        $extends = '';
        $implements = '';
        if ($token[0] === T_EXTENDS) {
            $body .= $this->_stream->skipWhitespaces();
            $body .= $extends = $this->_stream->skipWhile([T_STRING, T_NS_SEPARATOR]);
            $body .= $this->_stream->current();
            if ($this->_stream->current() !== '{') {
                $body .= $this->_stream->next('{');
            }
        } elseif ($token[0] === T_IMPLEMENTS) {
            $body .= $implements = $this->_stream->next('{');
            $implements = substr($implements, 0, -1);
        }
        $node = new BlockDef($body, 'class');
        $node->name = $name;
        $node->extends = $this->_normalizeClass($extends);
        $node->implements = $this->_normalizeImplements($implements);

        $this->_states['body'] .= $body;
        return $this->_states['current'] = $this->_contextualize($node);
    }
protected function _classNode ( ) { if ( substr ( $ this -> _states [ 'body' ] , - 2 ) === '::' ) { // Bails out on `::class` $ this -> _states [ 'body' ] .= 'class' ; return ; } $ this -> _codeNode ( ) ; $ token = $ this -> _stream -> current ( true ) ; $ body = $ token [ 1 ] ; $ body .= $ this -> _stream -> skipWhitespaces ( ) ; $ body .= $ name = $ this -> _stream -> current ( ) ; if ( $ name !== '{' ) { $ body .= $ this -> _stream -> next ( [ '{' , T_EXTENDS , T_IMPLEMENTS ] ) ; } else { $ name = '' ; } $ token = $ this -> _stream -> current ( true ) ; $ extends = '' ; $ implements = '' ; if ( $ token [ 0 ] === T_EXTENDS ) { $ body .= $ this -> _stream -> skipWhitespaces ( ) ; $ body .= $ extends = $ this -> _stream -> skipWhile ( [ T_STRING , T_NS_SEPARATOR ] ) ; $ body .= $ this -> _stream -> current ( ) ; if ( $ this -> _stream -> current ( ) !== '{' ) { $ body .= $ this -> _stream -> next ( '{' ) ; } } elseif ( $ token [ 0 ] === T_IMPLEMENTS ) { $ body .= $ implements = $ this -> _stream -> next ( '{' ) ; $ implements = substr ( $ implements , 0 , - 1 ) ; } $ node = new BlockDef ( $ body , 'class' ) ; $ node -> name = $ name ; $ node -> extends = $ this -> _normalizeClass ( $ extends ) ; $ node -> implements = $ this -> _normalizeImplements ( $ implements ) ; $ this -> _states [ 'body' ] .= $ body ; return $ this -> _states [ 'current' ] = $ this -> _contextualize ( $ node ) ; }
Build a class node.
Build a class node .