Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58874 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74027 invoked from network); 12 Mar 2012 13:47:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2012 13:47:09 -0000 Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-gx0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:36569] helo=mail-gx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/19-20445-C5EFD5F4 for ; Mon, 12 Mar 2012 08:47:09 -0500 Received: by ggmb2 with SMTP id b2so2891173ggm.29 for ; Mon, 12 Mar 2012 06:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=tOr7nH9IMIcrLsLJq21G1mP5GPgB8qfIWOb/vuPBgT4=; b=sJmY4J/46QqOM55bGvOQTftvSidYEluGuiOHSMFf9rtpdg+xnQ2z0sCfl/49M4qh9q oSCbNrNc0JNoIO41hAZcz3Tj40k40OxP2cpVxycJFGiruWUqBUcdyseT2ZjgbAyIrcN8 TsBzpdxDtj8b45E4icj/AsG37STYqAGgvH6rRu0g5qBX70rgQTSRgzjfYTDcX9XdDDnX YM1v9yb/lTM0toHHBZ2lwG1UlRhKT0OkqmlG817ygPPVJ1juW2GrLp0xyK5l9fwhQiqs SF26wwK0XtgpxNTqPXhckpgiXoK0P85JKaMwaAdI8Q+4qRhK8Wu5cainTe+/31KYFuZC xmxA== Received: by 10.100.249.1 with SMTP id w1mr4135872anh.38.1331560026245; Mon, 12 Mar 2012 06:47:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.147.172.8 with HTTP; Mon, 12 Mar 2012 06:46:44 -0700 (PDT) In-Reply-To: References: Date: Mon, 12 Mar 2012 14:46:44 +0100 Message-ID: To: Simon Schick Cc: Anthony Ferrara , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=0016368e1d5b5c8a7904bb0bfa23 Subject: Re: [PHP-DEV] [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters From: linepogl@gmail.com (Lazare Inepologlou) --0016368e1d5b5c8a7904bb0bfa23 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello Simon, First of all, none of your examples cover the case I mentioned, and so, my concerns are still valid. Secondly, you make some wrong assumptions about how this specific POC works. For example, you write: > function foo(int $d =3D 20) { var_dump($d); } > foo(null); // This should then also simply fail. Unless I am wrong, the patch will convert null to 0. Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel 2012/3/12 Simon Schick > 2012/3/12 Lazare Inepologlou > > > > function set_check_box_state( bool state =3D false ) { ... } > > set_check_box_state( null ); // null will be converted to false here..= . > > > > Therefore, this cannot work, unless the default value becomes null, whi= ch > > 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 ); // 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 > --0016368e1d5b5c8a7904bb0bfa23--