src/ContainerParser/ContainerParser.php
protected function getTokensUntil(int $type, bool $ignoreScopes = false) : array
    {
        $tokens = array();

        if (!is_array($type)) {
            $type = array($type);
        }

        while (!$this->parserIsDone() && !in_array($this->currentToken()->getType(), $type)) 
        {
            // if scopes should be ignored, we need to check if the current 
            // token opens one an then get all tokens inside the scope
            if ($ignoreScopes && $this->currentToken()->isType(T::TOKEN_SCOPE_OPEN)) 
            {
                foreach($this->getTokensUntilClosingScope(true, T::TOKEN_SCOPE_OPEN, T::TOKEN_SCOPE_CLOSE) as $token) {
                    $tokens[] = $token;
                }
            } else {
                $tokens[] = $this->currentToken();
                $this->skipToken();
            }
        }

        return $tokens;
    }
protected function getTokensUntil(int $type, bool $ignoreScopes = false) : array
    {
        $tokens = array();

        if (!is_array($type)) {
            $type = array($type);
        }

        while (!$this->parserIsDone() && !in_array($this->currentToken()->getType(), $type)) 
        {
            // if scopes should be ignored, we need to check if the current 
            // token opens one an then get all tokens inside the scope
            if ($ignoreScopes && $this->currentToken()->isType(T::TOKEN_SCOPE_OPEN)) 
            {
                foreach($this->getTokensUntilClosingScope(true, T::TOKEN_SCOPE_OPEN, T::TOKEN_SCOPE_CLOSE) as $token) {
                    $tokens[] = $token;
                }
            } else {
                $tokens[] = $this->currentToken();
                $this->skipToken();
            }
        }

        return $tokens;
    }
Get all tokens until the next token with given type

@param int                $type
@param bool                  $ignoreScopes if enabled, if the token is inside a new scope its ignored.
@return array[T]