original_string: private static function getProxy(?string $proxy, array $url): ?array
      {
          if (null === $proxy) {
              // Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
              $proxy = $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null;
  
              if ('https:' === $url['scheme']) {
                  $proxy = $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? $proxy;
              }
          }
  
          if (null === $proxy) {
              return null;
          }
  
          $proxy = (parse_url($proxy) ?: []) + ['scheme' => 'http'];
  
          if (!isset($proxy['host'])) {
              throw new TransportException('Invalid HTTP proxy: host is missing.');
          }
  
          if ('http' === $proxy['scheme']) {
              $proxyUrl = 'tcp://'.$proxy['host'].':'.($proxy['port'] ?? '80');
          } elseif ('https' === $proxy['scheme']) {
              $proxyUrl = 'ssl://'.$proxy['host'].':'.($proxy['port'] ?? '443');
          } else {
              throw new TransportException(sprintf('Unsupported proxy scheme "%s": "http" or "https" expected.', $proxy['scheme']));
          }
  
          return [
              'url' => $proxyUrl,
              'auth' => isset($proxy['user']) ? 'Basic '.base64_encode(rawurldecode($proxy['user']).':'.rawurldecode($proxy['pass'] ?? '')) : null,
          ];
      }
code: private static function getProxy(?string $proxy, array $url): ?array
      {
          if (null === $proxy) {
              // Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
              $proxy = $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null;
  
              if ('https:' === $url['scheme']) {
                  $proxy = $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? $proxy;
              }
          }
  
          if (null === $proxy) {
              return null;
          }
  
          $proxy = (parse_url($proxy) ?: []) + ['scheme' => 'http'];
  
          if (!isset($proxy['host'])) {
              throw new TransportException('Invalid HTTP proxy: host is missing.');
          }
  
          if ('http' === $proxy['scheme']) {
              $proxyUrl = 'tcp://'.$proxy['host'].':'.($proxy['port'] ?? '80');
          } elseif ('https' === $proxy['scheme']) {
              $proxyUrl = 'ssl://'.$proxy['host'].':'.($proxy['port'] ?? '443');
          } else {
              throw new TransportException(sprintf('Unsupported proxy scheme "%s": "http" or "https" expected.', $proxy['scheme']));
          }
  
          return [
              'url' => $proxyUrl,
              'auth' => isset($proxy['user']) ? 'Basic '.base64_encode(rawurldecode($proxy['user']).':'.rawurldecode($proxy['pass'] ?? '')) : null,
          ];
      }
code_tokens: private static function getProxy ( ? string $ proxy , array $ url ) : ? array { if ( null === $ proxy ) { // Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities $ proxy = $ _SERVER [ 'http_proxy' ] ?? ( \ in_array ( \ PHP_SAPI , [ 'cli' , 'phpdbg' ] , true ) ? $ _SERVER [ 'HTTP_PROXY' ] ?? null : null ) ?? $ _SERVER [ 'all_proxy' ] ?? $ _SERVER [ 'ALL_PROXY' ] ?? null ; if ( 'https:' === $ url [ 'scheme' ] ) { $ proxy = $ _SERVER [ 'https_proxy' ] ?? $ _SERVER [ 'HTTPS_PROXY' ] ?? $ proxy ; } } if ( null === $ proxy ) { return null ; } $ proxy = ( parse_url ( $ proxy ) ? : [ ] ) + [ 'scheme' => 'http' ] ; if ( ! isset ( $ proxy [ 'host' ] ) ) { throw new TransportException ( 'Invalid HTTP proxy: host is missing.' ) ; } if ( 'http' === $ proxy [ 'scheme' ] ) { $ proxyUrl = 'tcp://' . $ proxy [ 'host' ] . ':' . ( $ proxy [ 'port' ] ?? '80' ) ; } elseif ( 'https' === $ proxy [ 'scheme' ] ) { $ proxyUrl = 'ssl://' . $ proxy [ 'host' ] . ':' . ( $ proxy [ 'port' ] ?? '443' ) ; } else { throw new TransportException ( sprintf ( 'Unsupported proxy scheme "%s": "http" or "https" expected.' , $ proxy [ 'scheme' ] ) ) ; } return [ 'url' => $ proxyUrl , 'auth' => isset ( $ proxy [ 'user' ] ) ? 'Basic ' . base64_encode ( rawurldecode ( $ proxy [ 'user' ] ) . ':' . rawurldecode ( $ proxy [ 'pass' ] ?? '' ) ) : null , ] ; }
docstring: Loads proxy configuration from the same environment variables as curl when no proxy is explicitly set.
docstring_tokens: Loads proxy configuration from the same environment variables as curl when no proxy is explicitly set .