src/Jit/TokenStream.php
public function nextMatchingBracket()
    {
        if (!$this->valid()) {
            return;
        }

        $matches = ['(' => ')', '{' => '}', '[' => ']'];

        $token = $this->current();
        $content = $open = $token[0];

        if (!isset($matches[$open])) {
            return;
        }
        $level = 1;
        $close = $matches[$open];

        $start = $this->_current;
        $count = $this->count();
        $this->_current++;

        while ($this->_current < $count) {
            $type = $this->_data[$this->_current][0];
            if ($type === $close) {
                $level--;
            } elseif ($type === $open) {
                $level++;
            }
            $content .= $this->_data[$this->_current][1];
            if ($level === 0) {
                return $content;
            }
            $this->_current++;
        }
        $this->_current = $start;
    }
public function nextMatchingBracket()
    {
        if (!$this->valid()) {
            return;
        }

        $matches = ['(' => ')', '{' => '}', '[' => ']'];

        $token = $this->current();
        $content = $open = $token[0];

        if (!isset($matches[$open])) {
            return;
        }
        $level = 1;
        $close = $matches[$open];

        $start = $this->_current;
        $count = $this->count();
        $this->_current++;

        while ($this->_current < $count) {
            $type = $this->_data[$this->_current][0];
            if ($type === $close) {
                $level--;
            } elseif ($type === $open) {
                $level++;
            }
            $content .= $this->_data[$this->_current][1];
            if ($level === 0) {
                return $content;
            }
            $this->_current++;
        }
        $this->_current = $start;
    }
public function nextMatchingBracket ( ) { if ( ! $ this -> valid ( ) ) { return ; } $ matches = [ '(' => ')' , '{' => '}' , '[' => ']' ] ; $ token = $ this -> current ( ) ; $ content = $ open = $ token [ 0 ] ; if ( ! isset ( $ matches [ $ open ] ) ) { return ; } $ level = 1 ; $ close = $ matches [ $ open ] ; $ start = $ this -> _current ; $ count = $ this -> count ( ) ; $ this -> _current ++ ; while ( $ this -> _current < $ count ) { $ type = $ this -> _data [ $ this -> _current ] [ 0 ] ; if ( $ type === $ close ) { $ level -- ; } elseif ( $ type === $ open ) { $ level ++ ; } $ content .= $ this -> _data [ $ this -> _current ] [ 1 ] ; if ( $ level === 0 ) { return $ content ; } $ this -> _current ++ ; } $ this -> _current = $ start ; }
Move to the next matching bracket.

@return string|null Returns the skipped text content.
Move to the next matching bracket .