Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75507 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66794 invoked from network); 14 Jul 2014 19:09:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 19:09:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:48480] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/54-45205-50B24C35 for ; Mon, 14 Jul 2014 15:09:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 423568800F1 for ; Mon, 14 Jul 2014 15:09:55 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qXyfrs0hpfl6 for ; Mon, 14 Jul 2014 15:09:55 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id A86638800D0 for ; Mon, 14 Jul 2014 15:09:54 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <16D48604-0C0A-4613-91A4-21392E3A2636@ajf.me> Date: Mon, 14 Jul 2014 20:09:51 +0100 Content-Transfer-Encoding: quoted-printable Message-ID: <890B10EB-4988-4D3E-9798-AC5BA000E230@ajf.me> References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <16D48604-0C0A-4613-91A4-21392E3A2636@ajf.me> To: PHP internals X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: ajf@ajf.me (Andrea Faulds) On 14 Jul 2014, at 13:58, Andrea Faulds wrote: >=20 > One of the issues with the RFC as it stands is how to handle bool = casting. While int, float and string only allow lossless casting (with = the exception of objects, but we can=92t really do anything about that), = bool=92s behaviour at the moment is quite different. I don=92t think it = makes sense so I won=92t discuss the current behaviour, only possible = new ones. > Another option is go completely strict and allow only boolean values, = failing everything else. This would be unlike the int, float and string = hints, which are flexible and cast, but would be more helpful for = catching bugs. However, not casting at all isn=92t very =93PHP-like=94, = and forcing people to manually cast with (bool) might not be ideal. If = we were to go for this one, I might also accept objects casting to bool = (which the default handler does), because I don=92t want to stop = extension developers from making bool-like objects if they so please. I=92ve made the patch and RFC do this, at least for the time being. I=92m = still not really decided, nor is Anthony. The main advantage of being = completely strict is that it=92s fully lossless; (bool)(string)$x =3D=3D=3D= $x where $x was a boolean, but (string)(bool)$x !=3D=3D $x where $x was = a string. (Not necessarily, at least). This would make it an oddball among the scalars as it=92s completely = strict, and would require you to cast to bool explicitly in many cases=85 = but at the moment it *seems* to be the most sensible option to me. Still, we=92re both undecided. -- Andrea Faulds http://ajf.me/