Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75516 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90120 invoked from network); 14 Jul 2014 22:59:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 22:59:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.115 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.115 smtp115.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.115] ([108.166.43.115:48647] helo=smtp115.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/B1-15121-2E064C35 for ; Mon, 14 Jul 2014 18:59:47 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp7.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 9CB3E380752; Mon, 14 Jul 2014 18:59:44 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp7.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 400E1380A67; Mon, 14 Jul 2014 18:59:44 -0400 (EDT) X-Sender-Id: smalyshev@sugarcrm.com Received: from Stass-MacBook-Pro.local ([UNAVAILABLE]. [74.85.23.222]) (using TLSv1 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.2.4); Mon, 14 Jul 2014 22:59:44 GMT Message-ID: <53C460DF.5040304@sugarcrm.com> Date: Mon, 14 Jul 2014 15:59:43 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Andrea Faulds , Chris Wright CC: PHP internals References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <16D48604-0C0A-4613-91A4-21392E3A2636@ajf.me> <05CE2216-C5D9-4937-9F2E-AA1407284D9F@ajf.me> In-Reply-To: <05CE2216-C5D9-4937-9F2E-AA1407284D9F@ajf.me> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > I suggested on IRC that empty strings, TRUE, FALSE, NULL, and values > that validate for the int type hint could be accepted. Is that a good > idea? Though it feels a bit loose, I think it covers all the > important common use cases. Then you need to make all internal functions that accept bool work this way too. But I'm not sure why you need this. You accept that if("foo") works. Then why "function foo(bool $x) { if($x) { ... " should work differently? Yes, it is an edge case and bad code style. So are many other legal constructs. In my opinion, it is better to permit edge cases and be consistent than try to carve out perfect set of "what can be boolean" and get lost in the maze of exceptions and conditions. E.g. if we say we treat 1 and "1" mostly the same, then we should say "unless we convert them to bool in a context of a function call where they are not". I think it should be kept simpler - if we accept "foo" in boolean context, then we should just accept it. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/