Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75531 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45523 invoked from network); 15 Jul 2014 11:18:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2014 11:18:07 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.178 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.220.178 mail-vc0-f178.google.com Received: from [209.85.220.178] ([209.85.220.178:50553] helo=mail-vc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/59-15121-DED05C35 for ; Tue, 15 Jul 2014 07:18:06 -0400 Received: by mail-vc0-f178.google.com with SMTP id la4so3174612vcb.9 for ; Tue, 15 Jul 2014 04:18:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=8k9jvsxrqglv37IH23tMOScGy5kKyHTkJ1muUfNG9N8=; b=HuRFRrB1ibFUr8VojVrHTwPuWIM7Qy75OmJ/b8FimYI4gMP6M7ONV3MQTawxu0gvZh yu06sgGmjzQLSlKT8XEI1x28Sbz1lZi+MtXJYjIoDRDETHXXQLr0UnmFQ1ZiknlIP6FZ T/o9NLyRVKNSTzs+7mpg3VsU1vcE6tMHxqlk3By9zuhLRmlilSwbhB6FcLFSmN2hUzAd AqIE7Etx9r6arBgl1DzLWXAMuQ71ij98u/Lm2IwTuuUjtkoeGzD+128kVSxs92EEg+dV azttFIkwxKJoDenqmJpAqfcxeNJAZxyvei4/jVwEHuL4BPK+GkA9s3hW2FH7cy2/dYLo ZZow== X-Gm-Message-State: ALoCoQlpEeVHnw6UsEZAjvWVZRP9uF/kae4iQh1j/AqinYAwEJIGrc0zX7vFYm31hwltXNcmJFxfOK9e3TnrRdW+pn9IGRnu7niaA2cfBd+gNVU8z4vZR5uurr6bGVwdMVK11zVA8vwS X-Received: by 10.52.30.9 with SMTP id o9mr17940190vdh.15.1405423082287; Tue, 15 Jul 2014 04:18:02 -0700 (PDT) References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <16D48604-0C0A-4613-91A4-21392E3A2636@ajf.me> <05CE2216-C5D9-4937-9F2E-AA1407284D9F@ajf.me> <53C460DF.5040304@sugarcrm.com> In-Reply-To: <53C460DF.5040304@sugarcrm.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJuUFVOlGiX172RfpkkW7aXwqSXwwLGIEDMAn0sGnoDLh5SUQGHGGlvmhPYEyA= Date: Tue, 15 Jul 2014 14:18:01 +0300 Message-ID: To: Stas Malyshev , Andrea Faulds , Chris Wright Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Stas Malyshev [mailto:smalyshev@sugarcrm.com] > Sent: Tuesday, July 15, 2014 2:00 AM > To: Andrea Faulds; Chris Wright > Cc: PHP internals > Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) > > 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. Exactly. Zeev