> > 'on' is only true by "accident" though, because it is a non-empty
> > string, not because of its meaning, and then it is likely that the value
> > 'off' could also be added at some point - which also would be true.
>
> The reason I gave that particular example is that it's the default
> submission value for an HTML checkbox when checked; if it's not checked,
> it has no value at all (not even an empty string), so in that particular
> context there is no corresponding "off".
>

That's why you must test it with isset($_POST['checkbox_name']), *not* with
(bool)$_POST['checkbox_name'] or an implicit conversion.

if ( $nullable_float = type_coerce_or_return_default('?float', $var,
> false) === false ) { throw new TypeError; }
>

Missing parentheses around the assignment (VS the comparison)!


Only allowing the following values would make sense
> from my perspective:
>
> '1' => true
> 1 => true
> 1.0 => true
> '' => false
> '0' => false
> 0 => false
> 0.0 => false
>

Seems a reasonable compromise (between BC and bugs-protection).

Regards,

-- 
Guilliam Xavier

Reply via email to