private function prepareProxy(&$opt, $url)
    {
        $scheme = parse_url($url)['scheme'];
        if ($scheme === 'http' && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) {
            $proxy = !empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY'];
        }

        if ($scheme === 'https' && (!empty($_SERVER['HTTPS_PROXY']) || !empty($_SERVER['https_proxy']))) {
            $proxy = !empty($_SERVER['https_proxy']) ? $_SERVER['https_proxy'] : $_SERVER['HTTPS_PROXY'];
        }

        if (!empty($proxy)) {
            $proxy = str_replace(['http://', 'https://'], ['tcp://', 'ssl://'], $proxy);
            $opt['http']['proxy'] = $proxy;
        }
    }
private function prepareProxy(&$opt, $url)
    {
        $scheme = parse_url($url)['scheme'];
        if ($scheme === 'http' && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) {
            $proxy = !empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY'];
        }

        if ($scheme === 'https' && (!empty($_SERVER['HTTPS_PROXY']) || !empty($_SERVER['https_proxy']))) {
            $proxy = !empty($_SERVER['https_proxy']) ? $_SERVER['https_proxy'] : $_SERVER['HTTPS_PROXY'];
        }

        if (!empty($proxy)) {
            $proxy = str_replace(['http://', 'https://'], ['tcp://', 'ssl://'], $proxy);
            $opt['http']['proxy'] = $proxy;
        }
    }
private function prepareProxy ( & $ opt , $ url ) { $ scheme = parse_url ( $ url ) [ 'scheme' ] ; if ( $ scheme === 'http' && ( ! empty ( $ _SERVER [ 'HTTP_PROXY' ] ) || ! empty ( $ _SERVER [ 'http_proxy' ] ) ) ) { $ proxy = ! empty ( $ _SERVER [ 'http_proxy' ] ) ? $ _SERVER [ 'http_proxy' ] : $ _SERVER [ 'HTTP_PROXY' ] ; } if ( $ scheme === 'https' && ( ! empty ( $ _SERVER [ 'HTTPS_PROXY' ] ) || ! empty ( $ _SERVER [ 'https_proxy' ] ) ) ) { $ proxy = ! empty ( $ _SERVER [ 'https_proxy' ] ) ? $ _SERVER [ 'https_proxy' ] : $ _SERVER [ 'HTTPS_PROXY' ] ; } if ( ! empty ( $ proxy ) ) { $ proxy = str_replace ( [ 'http://' , 'https://' ] , [ 'tcp://' , 'ssl://' ] , $ proxy ) ; $ opt [ 'http' ] [ 'proxy' ] = $ proxy ; } }
Add proxy support to context if environment variable was set up

@param array $opt context options
@param string $url
Add proxy support to context if environment variable was set up