private static function myParse(string $host, ?HostnameInterface &$hostname = null, ?IPAddressInterface &$ipAddress = null, ?string &$error = null): bool
    {
        if ($host === '') {
            $error = 'Host "' . $host . '" is empty.';

            return false;
        }

        // Parse host as either a hostname or an IP address.
        try {
            $hostname = Hostname::parse($host);
        } catch (HostnameInvalidArgumentException $e) {
            $error = 'Host "' . $host . '" is invalid: ' . $e->getMessage();

            $ipAddress = IPAddress::tryParse($host);
            if ($ipAddress === null) {
                return false;
            }
        }

        return true;
    }