public function nextIfType(string $type, $value = null): bool
    {
        $currentToken = $this->getCurrent();
        $typeMatches = $currentToken !== null && $currentToken->type === $type;

        if ($typeMatches && ($value === null || $currentToken->value === $value)) {
            $this->next();

            return true;
        }

        return false;
    }