On Mon, 20 Oct 2014, Andrea Faulds wrote:

> Good evening,
> 
> I am presenting a new RFC to add a set of three functions to do validated 
> casts for scalar types:
> 
> https://wiki.php.net/rfc/safe_cast
> 
> Please read it.

> > The functions return FALSE on failure instead of NULL because:
> > - If strict type hinting were added, they would fail for a nullable
> >   typehint
> > - FALSE is a traditional error value in PHP
> > - NULL is used to signify the absence of a value - but what we want to
> >   signify is an invalid value (similar to 0 vs NaN)

But what about if we also would like a to_bool, which would accept 
"true", "false", "0", "1", true, false, 1 and 0?

Then to_bool() whould return false... or true? So hence, it should be 
NULL, and that would also be consistent with ext/filter.

cheers,
Derick

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

Reply via email to