check whether the next token of the current one is an exception

@param array     $tokens     list of tokens
@param integer   $ptr        current token index
@return boolean  returns true if the next token is an exception or false
546173
protected function isNextTokenAnException($tokens, $ptr)
    {
        return in_array($tokens[($ptr + 1)]['code'], $this->exceptions)
            && $tokens[($ptr + 1)]['column'] - $tokens[($ptr)]['column'] == 1;
    }
589495
protected function containsCreateMethod(array $tokens, int $stackPointer): bool
    {
        $begin = $tokens[$stackPointer]['scope_opener'] + 1;
        $end = $tokens[$stackPointer]['scope_closer'] - 1;

        for ($i = $begin; $i <= $end; $i++) {
            $token = $tokens[$i];

            if ($token['code'] === T_OBJECT_OPERATOR && $tokens[$i + 1]['code'] === T_STRING) {
                if (strpos($tokens[$i + 1]['content'], 'create') === 0) {
                    return true;
                }
            }
        }

        return false;
    }
852672
protected static function parseExpression(TokenIterator $tokens, \ArrayIterator $options) {
        $seq = static::parseSequence($tokens, $options);
        if ($tokens->current() != '|')
            return $seq;

        $result = null;
        if (sizeof($seq) > 1) $result = [new Required($seq)];
        else                  $result = $seq;

        while ($tokens->current() == '|') {
            $tokens->move();
            $seq = static::parseSequence($tokens, $options);
            if (sizeof($seq) > 1) $result[] = new Required($seq);
            else                  $result   = array_merge($result, $seq);
        }

        if (sizeof($result) > 1)
            return new Either($result);
        return $result;
    }
74682
public function apply(array &$tokens)
		{
		$r = 0;
		for ($i = 0, $l = count($tokens); $i < $l; $i++)
			{
			$current	= get_class($tokens[$i]);
			$next		= isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false;
			if (($current === "CssRulesetStartToken" && $next === "CssRulesetEndToken") ||
				($current === "CssAtKeyframesRulesetStartToken" && $next === "CssAtKeyframesRulesetEndToken" && !array_intersect(array("from", "0%", "to", "100%"), array_map("strtolower", $tokens[$i]->Selectors)))
				)
				{
				$tokens[$i]		= null;
				$tokens[$i + 1]	= null;
				$i++;
				$r = $r + 2;
				}
			}
		return $r;
		}
1131442
public function apply(array &$tokens)
		{
		for ($i = 0, $l = count($tokens); $i < $l; $i++)
			{
			$current	= get_class($tokens[$i]);
			$next		= isset($tokens[$i+1]) ? get_class($tokens[$i+1]) : false;
			if (($current === "CssRulesetDeclarationToken" && $next === "CssRulesetEndToken") ||
				($current === "CssAtFontFaceDeclarationToken" && $next === "CssAtFontFaceEndToken") || 
				($current === "CssAtPageDeclarationToken" && $next === "CssAtPageEndToken"))
				{
				$tokens[$i]->IsLast = true;
				}
			}
		return 0;
		}
1044541
protected function countGroupClose(Array $tokens)
	{
		return array_reduce($tokens, function ($carry, $item) {
			return $carry += $item instanceof Token\Group\Close;
		}, 0);
	}
136663
protected function advanceToNextToken(Iterator $tokens, $isStartToken)
    {
        if ($isStartToken) {
            $tokens->next();
        } elseif ($tokens->valid() && !$this->isEndToken($tokens->current())) {
            foreach ($this->getSubConsumers() as $consumer) {
                if ($consumer->isStartToken($tokens->current())) {
                    return;
                }
            }
            $tokens->next();
        }
    }
431597
private function getCurrentConstantKeyFromClassTokens($tokens)
    {
        $parsingStateConstDeclarationFound = false;
        $constDeclarationKey = 0;

        foreach ($tokens as $key => $token) {
            if (is_array($token) === true && $token[0] === T_CONST) {
                $parsingStateConstDeclarationFound = true;
                $constDeclarationKey = $key;
            }

            if ($parsingStateConstDeclarationFound === true && $token[0] === T_STRING) {
                if ($token[1] === $this->getName()) {
                    break;
                } else {
                    $parsingStateConstDeclarationFound = false;
                }
            }
        }

        return $constDeclarationKey;
    }
534916
protected function _isFirstContent(array $tokens, $phpOpenTagIndex) {
		for ($i = $phpOpenTagIndex - 1; $i >= 0; $i--) {
			if ($tokens[$i]['type'] !== T_INLINE_HTML) {
				return false;
			}
			if (trim($tokens[$i]['content']) !== '') {
				return false;
			}
		}

		return true;
	}
947853
protected function recurseArrayForTokens($arr, $tokens)
    {
        $out = [];
        foreach ($arr as $name => $value) {
            if (is_array($value)) {
                $out[$name] = $this->recurseArrayForTokens($value, $tokens);
                continue;
            }
            if (is_string($value)) {
                foreach ($tokens as $token => $tval) {
                    $value = str_replace($token, $tval, $value);
                }
                $out[$name] = $value;
                continue;
            }
            $out[$name] = $value;
        }

        return $out;
    }
105065
public function setTokens(array $tokens)
    {
        if (count($tokens) > self::MULTICAST_MAX_TOKENS) {
            throw new \RuntimeException(sprintf('Too many tokens in the list. %s tokens max.', self::MULTICAST_MAX_TOKENS));
        }

        return parent::setTokens($tokens);
    }
1328355
public function next()
    {
        if (!mb_strlen($this->input)) {
            return false;
        }

        foreach ($this->engine->getPatterns() as $pattern) {
            if ($token = $this->scan($pattern->regex, $pattern->type)) {
                if (in_array($pattern->type, $this->disallow)) {
                    throw new Exception($pattern->type . ' is disallowed.', 3);
                }

                return $token;
            }
        }

        throw new Exception('Unknow pattern found at: ' . mb_substr($this->input, 0, 100), 12);
    }
280104
public function nextOf($tokenNames)
    {
        $i = $this->index+1;
        $len = count($this->tokens);
        while ($i < $len) {
            $tok = $this->tokens[$i][0];
            if (in_array($tok, $tokenNames)) {
                return $tok;
            }
            $i++;
        }
        return null;
    }
334811
public static function isReserved(Tokenizer $tokenizer, $string, $previous)
    {
        $tokenData = [];

        if (!$tokenizer->getNextToken() && self::isReservedPrecededByDotCharacter($previous)) {
            $upperCase = \strtoupper($string);

            self::getReservedString($tokenData, Tokenizer::TOKEN_TYPE_RESERVED_TOP_LEVEL, $string, $tokenizer);
            self::getReservedString($tokenData, Tokenizer::TOKEN_TYPE_RESERVED_NEWLINE, $upperCase, $tokenizer);
            self::getReservedString($tokenData, Tokenizer::TOKEN_TYPE_RESERVED, $string, $tokenizer);

            $tokenizer->setNextToken($tokenData);
        }
    }
277922
protected function calculateExpectedIndent(array $tokens, $stackPtr)
    {
        $conditionStack = array();

        // Empty conditions array (top level structure).
        if (empty($tokens[$stackPtr]['conditions']) === true) {
            return 1;
        }

        $tokenConditions = $tokens[$stackPtr]['conditions'];
        foreach ($tokenConditions as $id => $condition) {
            // If it's an indenting scope ie. it's not in our array of
            // scopes that don't indent, add it to our condition stack.
            if (in_array($condition, $this->nonIndentingScopes) === false) {
                $conditionStack[$id] = $condition;
            }
        }

        return ((count($conditionStack) * $this->indent) + 1);

    }
586890
protected static function parseAtom(TokenIterator $tokens, \ArrayIterator $options) {
        $tokenError = $tokens->getTokenError();
        $token      = $tokens->current();
        $result     = [];

        if ($token=='(' || $token=='[') {
            $tokens->move();

            static $index; !$index && $index = [
                '(' => [')', Required::class],
                '[' => [']', Optional::class],
            ];
            list ($matching, $patternClass) = $index[$token];

            $result = new $patternClass(static::parseExpression($tokens, $options));
            if ($tokens->move() != $matching)
                throw new $tokenError('Unmatched "'.$token.'"');
            return [$result];
        }
        elseif ($token == 'options') {
            $tokens->move();
            return [new OptionsShortcut()];
        }
        elseif (strpos($token, '--')===0 && $token!='--') {
            return static::parseLong($tokens, $options);
        }
        elseif (strpos($token, '-')===0 && $token!='-' && $token!='--') {
            return static::parseShort($tokens, $options);
        }
        elseif ((strpos($token, '<')===0 && strEndsWith($token, '>')) || static::isUpperCase($token)) {
            return [new Argument($tokens->move())];
        }
        else {
            return [new Command($tokens->move())];
        }
    }
730235
public static function tokenNextCharacterIsNumber(&$tokens, $i)
    {
        return (isset($tokens[$i + 1])
            && $tokens[$i + 1][Tokenizer::TOKEN_TYPE] === Tokenizer::TOKEN_TYPE_NUMBER);
    }