Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58871 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61144 invoked from network); 12 Mar 2012 12:39:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2012 12:39:48 -0000 Authentication-Results: pb1.pair.com header.from=simonsimcity@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=simonsimcity@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: simonsimcity@googlemail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:53766] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/96-20445-39EED5F4 for ; Mon, 12 Mar 2012 07:39:48 -0500 Received: by yenl5 with SMTP id l5so2803161yen.29 for ; Mon, 12 Mar 2012 05:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=k60vZJo9IX5uBykTsNbOoPLw//oRMKuRC7N9IeAps9w=; b=qTrcaoEoSrOsFd8KNH0acEbbBoYkymSm6hwJM13aDWtuOE81ERNWRJWRpnPEilIkbI MZk8Z8ArTAdda6SMmnubKzZiBI2FK2CQN/OjokrAjgOvlIdsCshqEdblWCmpIzyog4Th BEGrTPD+UKaASfsoqpkfGk0u0y/sGsknX6FbYYlvCYaqM6+6jtgLwkEN0wuzlx0GLhg0 BLxIBmSU01qNdk9tUJ+50nVOq4+EIZ7LwddXxEp5kgEhpnzTAcDvUs2+CbOgEeanHXLZ TZndE+2COXK33JwqOIkXeU829mMC4hUyz/Lz8bGiWsh9f6L/B0N9HIkYfAjiB1nmTkkQ HDiQ== MIME-Version: 1.0 Received: by 10.182.155.68 with SMTP id vu4mr7177207obb.61.1331555985382; Mon, 12 Mar 2012 05:39:45 -0700 (PDT) Received: by 10.60.63.70 with HTTP; Mon, 12 Mar 2012 05:39:45 -0700 (PDT) In-Reply-To: References: Date: Mon, 12 Mar 2012 13:39:45 +0100 Message-ID: To: Lazare Inepologlou Cc: Anthony Ferrara , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters From: simonsimcity@googlemail.com (Simon Schick) 2012/3/12 Lazare Inepologlou > > function set_check_box_state( bool state =3D false ) { ... } > set_check_box_state( null ); =C2=A0// null will be converted to false her= e... > > Therefore, this cannot work, unless the default value becomes null, which > is against the requirements. What I suggest is something like this: > > function set_check_box_state( bool? state =3D false ) { ... } > set_check_box_state( null ); =C2=A0// works fine > > In my opinion this is much clearer, as it separates the notions of the > type > and that of the default value. > > > Lazare INEPOLOGLOU > Ing=C3=A9nieur Logiciel Hi Lazare, I'd like to keep the accptance of null as it is for classes and arrays. Here's an example I wrote earlier: function foo(array $d =3D array()) { var_dump($d); } foo(null); // This fails with the message: Argument 1 passed to foo() must be an array, null given As this code fails I'd not expect to change this behavior for the new feature we're discussing here. function foo(int $d =3D 20) { var_dump($d); } foo(null); // This should then also simply fail. Don't care about what's the default-value or defined type. function foo(int $d =3D null) { var_dump($d); } foo(null); // And this should pass it through, providing the NULL-value in the function. function foo(int $d =3D 20) { var_dump($d); } foo( (int)null ); // This can provide 0 as the programmer forcing it to be an integer before putting it into this function-call. I would personally not like to give the user the option to set a null-value if it's not the default. But .. I don't wanna screw up your idea. Bye Simon