On 02/17/2015 01:11 AM, Benjamin Eberlei wrote:
> I think curl_setopt is a misleading example in the typehinting
> discussion, because
> this kind of API does not benefit from it. The third argument depends
> on the second argument and requires a "generic" type in code:
> 
> curl_setopt(resource $ch, int $option, mixed $data);
> 
> It won't be possible to change this (or any similar API) with strict
> type hints. 
> 
> The code to convert a boolean $data to integer in the VERIFYPEER case is
> manually
> implemented and therefore subject to the implementors design decisions.

Sure, I realize this, but it is the bool->int coercion example that is
always brought up. A static analysis type checker would have trouble
catching this, but both PHP and Hack apply that coercion at runtime:

       case CURLOPT_SSL_VERIFYHOST:
           if(Z_BVAL_PP(zvalue) == 1) {

The runtime could say, hey, I am in strict mode here and you are passing
me an array of strings which I am coercing to a boolean. Not cool.

-Rasmus

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to