original_string: private static function dnsResolve(array $url, NativeClientState $multi, array &$info, ?\Closure $onProgress): array
      {
          if ($port = parse_url($url['authority'], PHP_URL_PORT) ?: '') {
              $info['primary_port'] = $port;
              $port = ':'.$port;
          } else {
              $info['primary_port'] = 'http:' === $url['scheme'] ? 80 : 443;
          }
  
          $host = parse_url($url['authority'], PHP_URL_HOST);
  
          if (null === $ip = $multi->dnsCache[$host] ?? null) {
              $now = microtime(true);
  
              if (!$ip = gethostbynamel($host)) {
                  throw new TransportException(sprintf('Could not resolve host "%s".', $host));
              }
  
              $info['namelookup_time'] += microtime(true) - $now;
              $multi->dnsCache[$host] = $ip = $ip[0];
          }
  
          $info['primary_ip'] = $ip;
  
          if ($onProgress) {
              // Notify DNS resolution
              $onProgress();
          }
  
          return [$host, $port, substr_replace($url['authority'], $ip, -\strlen($host) - \strlen($port), \strlen($host))];
      }
code: private static function dnsResolve(array $url, NativeClientState $multi, array &$info, ?\Closure $onProgress): array
      {
          if ($port = parse_url($url['authority'], PHP_URL_PORT) ?: '') {
              $info['primary_port'] = $port;
              $port = ':'.$port;
          } else {
              $info['primary_port'] = 'http:' === $url['scheme'] ? 80 : 443;
          }
  
          $host = parse_url($url['authority'], PHP_URL_HOST);
  
          if (null === $ip = $multi->dnsCache[$host] ?? null) {
              $now = microtime(true);
  
              if (!$ip = gethostbynamel($host)) {
                  throw new TransportException(sprintf('Could not resolve host "%s".', $host));
              }
  
              $info['namelookup_time'] += microtime(true) - $now;
              $multi->dnsCache[$host] = $ip = $ip[0];
          }
  
          $info['primary_ip'] = $ip;
  
          if ($onProgress) {
              // Notify DNS resolution
              $onProgress();
          }
  
          return [$host, $port, substr_replace($url['authority'], $ip, -\strlen($host) - \strlen($port), \strlen($host))];
      }
code_tokens: private static function dnsResolve ( array $ url , NativeClientState $ multi , array & $ info , ? \ Closure $ onProgress ) : array { if ( $ port = parse_url ( $ url [ 'authority' ] , PHP_URL_PORT ) ? : '' ) { $ info [ 'primary_port' ] = $ port ; $ port = ':' . $ port ; } else { $ info [ 'primary_port' ] = 'http:' === $ url [ 'scheme' ] ? 80 : 443 ; } $ host = parse_url ( $ url [ 'authority' ] , PHP_URL_HOST ) ; if ( null === $ ip = $ multi -> dnsCache [ $ host ] ?? null ) { $ now = microtime ( true ) ; if ( ! $ ip = gethostbynamel ( $ host ) ) { throw new TransportException ( sprintf ( 'Could not resolve host "%s".' , $ host ) ) ; } $ info [ 'namelookup_time' ] += microtime ( true ) - $ now ; $ multi -> dnsCache [ $ host ] = $ ip = $ ip [ 0 ] ; } $ info [ 'primary_ip' ] = $ ip ; if ( $ onProgress ) { // Notify DNS resolution $ onProgress ( ) ; } return [ $ host , $ port , substr_replace ( $ url [ 'authority' ] , $ ip , - \ strlen ( $ host ) - \ strlen ( $ port ) , \ strlen ( $ host ) ) ] ; }
docstring: Resolves the IP of the host using the local DNS cache if possible.
docstring_tokens: Resolves the IP of the host using the local DNS cache if possible .