Well, I've found out that I need to set proxy type to CURLPROXY_SOCKS5_HOSTNAME:
curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
It works fine.