private static function myValidateQueryString(?string $queryString, ?string &$error): bool
    {
        if ($queryString === null) {
            return true;
        }

        if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $queryString, $matches)) {
            $error = 'Query string "' . $queryString . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }