Match a token in the lexer.

@param int $type

@return mixed

@throws SyntaxErrorException
424657
private function match(int $type)
    {
        if (! $this->lexer->isNextToken($type)) {
            $this->syntaxError();
        }

        $value = $this->lexer->lookahead['value'];
        $this->lexer->moveNext();

        return $value;
    }
456293
public function getToken( $type = 'csrf' ) {
		// If we don't already have the token that we want
		if ( !array_key_exists( $type, $this->tokens ) ) {
			$this->logger->log( LogLevel::DEBUG, 'Getting fresh token', [ 'type' => $type ] );

			// If we know that we don't have the new module mw<1.25
			if ( $this->usePre125TokensModule ) {
				return $this->reallyGetPre125Token( $type );
			} else {
				return $this->reallyGetToken( $type );
			}

		}

		return $this->tokens[$type];
	}
1017098
public function contains($type)
	{
		foreach($this->tokens as $token)
		{
			if($token->is($type))
			{
				return true;
			}
		}
		
		return false;
	}
1180878
public static function hasSyntax($token, $syntax = self::VAR_SYNTAX)
    {
        if (!\is_array($token)) {
            return false;
        }

        $regexp = \sprintf('#%s#', $syntax);

        return (bool) \preg_match($regexp, $token[1]);
    }
1341193
public static function getTokenSyntax($tokenType)
    {
        $tokenSyntax = array();
        // Punctuation
        if ($tokenType & self::T_COMMA) {
            $tokenSyntax[] = ',';
        }

        // Recognize numeric values
        if ($tokenType & self::T_FLOAT) {
            $tokenSyntax[] = 'simple float';
        }
        if ($tokenType & self::T_INTEGER) {
            $tokenSyntax[] = 'simple integer';
        }
        if ($tokenType & self::T_INPUT_PARAMETER) {
            $tokenSyntax[] = '/[a-z_][a-z0-9_]*/';
        }

        // Recognize quoted strings
        if ($tokenType & self::T_STRING) {
            $tokenSyntax[] = '"value" or \'value\'';
        }

        // Comparison operator
        if ($tokenType & self::T_EQUALS) {
            $tokenSyntax[] = '=';
        }
        if ($tokenType & self::T_NOT_EQUALS) {
            $tokenSyntax[] = '≠ or !=';
        }
        if ($tokenType & self::T_GREATER_THAN) {
            $tokenSyntax[] = '>';
        }
        if ($tokenType & self::T_GREATER_THAN_EQUALS) {
            $tokenSyntax[] = '≥ or >=';
        }
        if ($tokenType & self::T_LOWER_THAN) {
            $tokenSyntax[] = '<';
        }
        if ($tokenType & self::T_LOWER_THAN_EQUALS) {
            $tokenSyntax[] = '≤ or <=';
        }

        // Composite operator
        if ($tokenType & self::T_AND) {
            $tokenSyntax[] = '&';
        }
        if ($tokenType & self::T_NOT_AND) {
            $tokenSyntax[] = '!&';
        }
        if ($tokenType & self::T_OR) {
            $tokenSyntax[] = '|';
        }
        if ($tokenType & self::T_NOT_OR) {
            $tokenSyntax[] = '!|';
        }
        if ($tokenType & self::T_XOR) {
            $tokenSyntax[] = '⊕ or ^|';
        }

        // Brace
        if ($tokenType & self::T_OPEN_PARENTHESIS) {
            $tokenSyntax[] = '(';
        }
        if ($tokenType & self::T_CLOSE_PARENTHESIS) {
            $tokenSyntax[] = ')';
        }
        if ($tokenType & self::T_OPEN_SQUARE_BRACKET) {
            $tokenSyntax[] = '[';
        }
        if ($tokenType & self::T_NOT_OPEN_SQUARE_BRACKET) {
            $tokenSyntax[] = '![';
        }
        if ($tokenType & self::T_CLOSE_SQUARE_BRACKET) {
            $tokenSyntax[] = ']';
        }
        if ($tokenType & self::T_DOUBLE_OPEN_CURLY_BRACKET) {
            $tokenSyntax[] = '{{';
        }
        if ($tokenType & self::T_NOT_DOUBLE_OPEN_CURLY_BRACKET) {
            $tokenSyntax[] = '!{{';
        }
        if ($tokenType & self::T_DOUBLE_CLOSE_CURLY_BRACKET) {
            $tokenSyntax[] = '}}';
        }

        return $tokenSyntax;
    }
134383
public static function TokenizedTypeFromXmlType( $type )
	{
		// Sanity check
		if ( is_null( $type )  || ! is_string( $type ) )
		{
			return XmlTokenizedType::None;
		}

		$types = SchemaTypes::getInstance();
		$atom = $types->getAtomicType( $type );

		return isset( XmlTokenizedType::$typeToCodeMap[ $atom ] )
			? XmlTokenizedType::$typeToCodeMap[ $atom ]
			: XmlTokenizedType::None;
	}
322698
protected function matchTokenTextAtCursor(int $type)
    {
        $result = preg_match($this->getTokenPattern($type), $this->getTextAtCursor(), $matches);
        PregHelper::assertMatchResult(
            $result,
            RegExpException::class,
            "Failed to match token text due to regular expression error"
        );
        if (1 === $result) {
            $text = $matches[0];
            if (strlen($text) == 0) {
                throw new LengthException("Matched token text is empty");
            }
        } else {
            $text = null;
        }
        return $text;
    }
139908
public function getTokens($type) {
        $tokens = $this->client->tokens(array('type' => implode('|', $type)));
        if (!empty($tokens['warnings']) || empty($tokens['tokens'])) {
            throw new SessionException("Error while getting tokens from wiki. ".json_encode($tokens));
        }
        $result = (array) $tokens['tokens'];
        $this->tokencache = array_merge($this->tokencache, $result );
        return $result;
    }
474232
public function getSignatureAlgorithm($type)
    {
        if (!isset($this->signatureAlgorithms[$type])) {
            throw new \RuntimeException('Algorithm not configured: ' . $type);
        }
        return $this->signatureAlgorithms[$type];
    }
742657
private function isToken($token, $typeMask = null)
    {
        if (!$token instanceof Token) {
            return false;
        }

        if (null === $typeMask || $token->type & $typeMask) {
            return true;
        }

        return false;
    }
1010231
public function expect($type, $value = null, $message = null)
    {
        $token = $this->current;
        if (!$token->test($type, $value)) {
            throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message.'. ' : '', $token->type, $token->value, $type, $value ? sprintf(' with value "%s"', $value) : ''), $token->cursor);
        }
        $this->next();
    }
463385
protected function formatType($type)
    {
        if (preg_match('/^(?:(.*)\.)?_(.*)$/', $type, $matches)) {
            if ($matches[1] !== '') {
                return sprintf("%s.%s[]", $matches[1], $matches[2]);
            } else {
                return $matches[2].'[]';
            }
        } else {
            return $type;
        }
    }
237582
public static function get($type)
    {
        if (\is_string($type))
        {
            if (\defined(static::class . '::' . $type))
            {
                return \constant(static::class . '::' . $type);
            }

            if (\defined($type))
            {
                return \constant($type);
            }

            return \T_STRING;
        }

        foreach (static::constants() as $name => $value)
        {
            if ($value === $type)
            {
                return $name;
            }
        }

        $token = \token_name($type);

        if ($token === 'UNKNOWN')
        {
            return 'T_STRING';
        }

        return $token;
    }
1330122
public function getNextIdentifierOrStar()
    {
        $next = $this->getNext();

        if ($next->isIdentifier()) {
            return $next->getValue();
        }

        if ($next->isDelimiter(['*'])) {
            return;
        }

        throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next);
    }
1164564
public function getForeignKeyMatchClauseSQL($type)
    {
        switch ((int) $type) {
            case self::FOREIGN_KEY_MATCH_SIMPLE:
                return 'SIMPLE';

                break;
            case self::FOREIGN_KEY_MATCH_FULL:
                return 'FULL';

                break;
            case self::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE:
                return 'UNIQUE SIMPLE';

                break;
            case self::FOREIGN_KEY_MATCH_FULL_UNIQUE:
                return 'UNIQUE FULL';
            default:
                throw new InvalidArgumentException('Invalid foreign key match type: ' . $type);
        }
    }
553650
public function anInstanceOf($type): Matcher
    {
        if (is_object($type)) {
            $type = get_class($type);
        }

        return new InstanceOfMatcher($type);
    }
1307669
def _expect_token(lexer, types):
    """"""
    tok = next(lexer)
    if any(isinstance(tok, t) for t in types):
        return tok
    else:
        raise Error("unexpected token: " + str(tok))