Zeev,

>> You also stated above that false->bool is not supported (I'm guessing
> you
>> meant float->bool). So users would be able to pass "4.3" to a bool
> typehint,
>> but not 4.3? This behavior seems very arbitrary and confusing.
>
> It may be confusing, but only academically so.  Again, this approach tries
> to work well with real world usage - and reject conversions which are
> likely to be erroneous.  "4.3" may look like a floating point number but
> in the context of conversion to boolean, that doesn't matter much.  It's a
> string.

Doesn't that contradict what you've been saying the whole time about
how "13" and 13 and 13.0 are really "the same thing", and as such
should be coerced?

> function bar(float $x)
> $foo = 1;
> bar($foo);  // will definitely fail in strict mode

No, actually it won't fail in strict mode:
https://wiki.php.net/rfc/scalar_type_hints_v5#integers_should_be_accepted_for_strict_float_arguments

Anthony

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to