Returns a Token if type is matched, otherwise fails the parser

@param string $type Type of token

@throws \LogicException

@return Token
339371
public function expect($type)
    {
        $token = $this->current();
        if (!$this->is($type)) {
            if (is_array($type)) {
                $type = implode(' or ', $type);
            }
            $actual = sprintf('<%s:%s>', $token->getType(), $token->getValue());
            throw new \LogicException(sprintf('Syntax Error: %s expected %s given at line %d', $type, $actual, $token->getLine()));
        }
        $this->next();

        return $token;
    }
880387
public static function input(string $type)
    {
        $self = self::$input[$type] ?? new self;

        self::$input[$type] = $self;

        switch (strtoupper($type)) {
            case 'GET':
            case 'POST':
                $self->params = filter_input_array(constant('INPUT_' . $type)) ?? [];
                break;
            case 'PUT':
            case 'DELETE':
                $self->params = self::getParsedInput();
                break;
        }

        return function ($key = null) use ($self) {
            $self->key = $key;

            return $self;
        };
    }
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;
	}
881129
protected function getTokenPattern(int $type): string
    {
        $patternMap = [
            Token::TYPE_SLASH => '/',
            Token::TYPE_ESCAPED => '~(0|1)',
            Token::TYPE_UNESCAPED => '[^/~]',
            Token::TYPE_ERROR_INVALID_ESCAPE => '~',
        ];
        if (!isset($patternMap[$type])) {
            throw new DomainException("Unknown token type: {$type}");
        }
        $pattern = $patternMap[$type];
        return "#{$pattern}#uA";
    }
40473
public function type($type)
    {
        $fail = false;

        $value = $this->value();

        if ($value === null) {
            return $this;
        }

        switch (strtolower($type)) {
            case 'bool':
            case 'boolean':
                if ($fail = !is_bool($value)) {
                    $message = sprintf('%s accepts only boolean values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'int':
            case 'integer':
                if ($fail = !is_int($value)) {
                    $message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'num':
            case 'numeric':
                $fail = !is_numeric($value);
                $message = sprintf('%s accepts only numeric values as argument %d.', $this->getCommandName(),
                    $this->key + 1);
                break;

            case 'str':
            case 'string':
                if ($fail = !is_string($value)) {
                    $message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'array':
                if ($fail = !is_array($value)) {
                    $message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'closure':
                if ($fail = !$value instanceof \Closure) {
                    $message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;

            case 'digit':
                if ($fail = !$this->isDigit($value)) {
                    $message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(),
                        $this->key + 1);
                }
                break;
        }

        if ($fail) {
            $message = $message ?? sprintf('Missing argument for %d.', $this->key);

            throw new \Hail\Image\Exception\InvalidArgumentException($message);
        }

        return $this;
    }
1148264
public static function getCodeByType($type)
    {
        if (isset(self::$typeList[$type])) {
            return self::$typeList[$type];
        } else {
            return false;
        }
    }
363672
public static function parse(string $type): self
    {
        static $parser = null;
        if (null === $parser) {
            $parser = new Parser();
        }

        return $parser->parse($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;
    }
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;
    }
947670
public function expect($type)
    {
        $node = $this->current();
        if (!$this->is($type)) {
            if (is_array($type)) {
                $type = implode(' or ', $type);
            }
            $actual = sprintf('<%s:%s>', $node->getType(), $node->getValue());
            throw new \LogicException(sprintf('Syntax Error: %s expected %s given', $type, $actual));
        }
        $this->next();

        return $node;
    }
436966
public function setMatchType(string $matchType): self
    {
        if (!isset($this->field)) {
            throw new \LogicException();
        }

        $this->matchType = $matchType;

        return $this;
    }
222400
public function getUriForDiagrammType($type)
    {
        switch ($type) {
            case Diagramm::TYPE_ACTIVITY:
                $uri = $this->getOptions()->getYumlActivityDiagrammUrl();
                break;
            case Diagramm::TYPE_CLASS:
                $uri = $this->getOptions()->getYumlClassDiagrammUrl();
                break;
            case Diagramm::TYPE_DIAGRAMM:
                throw new \InvalidArgumentException('Unsupported diagramm type "' . $type . '"');
                break;
            case Diagramm::TYPE_USE_CASE:
                $uri = $this->getOptions()->getYumlUseCaseDiagrammUrl();
                break;
            default:
                throw new \InvalidArgumentException('Unkown diagramm type "' . $type . '"');
                break;
        }
        return $uri;
    }
62155
public function withType($type)
    {
        $choices = [
            PriceInterface::TYPE_OWN,
            PriceInterface::TYPE_RENT,
        ];

        Assertion::choice($type, $choices);

        $instance = clone $this;

        $instance->type = $type;

        return $instance;
    }
508745
public function forType(string $type): HandlerInterface
    {
        if ($type !== $this->getType()) {
            throw new LogicException("Unable to use " . get_class($this) . " to cast to $type");
        }
        
        return $this;
    }
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;
    }
883757
protected function getGraphQLType(?string $type):?string
    {
        switch ($type) {
            case DoctrineType::BOOLEAN:
                $type = Types::BOOLEAN;
                break;
            case DoctrineType::DECIMAL:
            case DoctrineType::FLOAT:
                $type = Types::FLOAT;
                break;
            case DoctrineType::INTEGER:
            case DoctrineType::BIGINT:
            case DoctrineType::SMALLINT:
                $type = Types::INT;
                break;
            case DoctrineType::STRING:
            case DoctrineType::TEXT:
            case DoctrineType::GUID:
                $type = Types::STRING;
                break;
            case DoctrineType::TARRAY:
            case DoctrineType::SIMPLE_ARRAY:
            case DoctrineType::JSON_ARRAY:
                $type = Types::nonNull(Types::listOf(Types::STRING));
                break;
            case DoctrineType::TIME:
            case DoctrineType::TIME_IMMUTABLE:
                $type = Types::TIME;
                break;
            case DoctrineType::DATE:
                $type = Types::DATE;
                break;
            case DoctrineType::DATETIME:
                $type = Types::DATETIME;
                break;
        }

        return $type;
    }
957809
public function getKey(string $key = null): string
    {
        if ($key === null) {
            return $this->defaultKey;
        }

        if (!isset($this->tokens[$key])) {
            throw new \LogicException(sprintf('Token with name %s could not be found', $key));
        }

        return $key;
    }