Nobody says it, but the commented example here shows that we should use tcp://
in the proxy protocol, while cURL accepts http
... So this minimal script fixed the error:
$url = 'https://getcomposer.org/versions';
$opts = [
'http' => [ 'proxy' => 'tcp://proxy.redecorp.br:8080' ]
];
$context = stream_context_create($opts);
echo file_get_contents($url,false,$context);