Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78205 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48881 invoked from network); 21 Oct 2014 15:26:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Oct 2014 15:26:21 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:40626] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/B8-02077-A1B76445 for ; Tue, 21 Oct 2014 11:26:21 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 59A4C11BAEF; Tue, 21 Oct 2014 16:26:15 +0100 (BST) Date: Tue, 21 Oct 2014 11:26:14 -0400 (EDT) X-X-Sender: derick@whisky.home.derickrethans.nl To: Andrea Faulds cc: PHP Internals In-Reply-To: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> Message-ID: References: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] [RFC] Safe Casting Functions From: derick@php.net (Derick Rethans) 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