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;
    }