private function doValidateOptions(array $options = []): array
    {
        if (
            isset($this->options['curl'], $options['curl']) &&
            \is_array($this->options['curl']) &&
            \is_array($options['curl'])
        ) {
            $parameters['curl'] = \array_replace($this->options['curl'], $options['curl']);
        }

        $options = \array_replace($this->options, $options);

        foreach (static::$types as $k => $v) {
            $type = \gettype($options[$k]);
            $v = (array) $v;

            $checked = false;
            foreach ($v as $t) {
                if ($t === $type || ($t === 'callable' && \is_callable($options[$k]))) {
                    $checked = true;
                    break;
                }
            }

            if (!$checked) {
                $should = \implode(', ', $v);
                throw new InvalidArgumentException("'$k' options should be '$should', but get '$type'");
            }
        }

        return $options;
    }