Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80125 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99238 invoked from network); 3 Jan 2015 20:10:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2015 20:10:12 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.207 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.207 imap2-2.ox.privateemail.com Received: from [192.64.116.207] ([192.64.116.207:46169] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/02-21228-3AC48A45 for ; Sat, 03 Jan 2015 15:10:11 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 6221A8C007D; Sat, 3 Jan 2015 15:10:08 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kU9LLfSA1zso; Sat, 3 Jan 2015 15:10:08 -0500 (EST) Received: from [192.168.0.13] (unknown [94.13.96.117]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 06CAC8C0009; Sat, 3 Jan 2015 15:10:05 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Sat, 3 Jan 2015 20:09:32 +0000 Cc: Pierre Joye , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <93B11897-3B8E-4D71-A8EB-A2D67B5446E9@ajf.me> References: <41D5BB0B-73AF-488E-968D-90B2878E3178@ajf.me> <360F9366-07C2-4C7A-AC3C-D482AFDD9838@ajf.me> To: "Sebastian B.-Hagensen" X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints From: ajf@ajf.me (Andrea Faulds) Hi Sebastian, > On 3 Jan 2015, at 19:46, Sebastian B.-Hagensen = wrote: >>=20 >> Yeah, I don=E2=80=99t like this behaviour much. I want to avoid = inconsistency with the behaviour of extension functions (i.e. = zend_parse_parameters) where possible, though. Since this has come up so = much, I should probably make an RFC to change this aspect of ZPP=E2=80=99s= behaviour. >=20 > That RFC should probably be voted on before this RFC proceeds into = voting. That would be the idea. > After skimming through the RFC I'm unsure what the following code = would produce: >=20 > function test(int $a, int $b) {} >=20 > test("10.4", 10.6); >=20 > If a warning/notice is raised, fine. If it will just result in $a =3D=3D= =3D > (int)10 && $b =3D=3D=3D(int)10 : The first argument would be converted to 10 and a notice (=E2=80=9CNon = well formed numeric string=E2=80=9D). The second would also be converted = to 10, but silently. I agree with your sentiments about data loss, but I am reluctant to = deviate much from the behaviour of internal functions to avoid the = inconsistency that plagued the previous RFC. > If type annotations wouldn't go beyond the safety that php currently > provides by converting in specific contexts and casting what is the > benefit in adding them? They=E2=80=99re still much safer than what we currently have. An = unhinted parameter will accept anything. A scalar hinted parameter = won=E2=80=99t accept non-scalars, and will only accept certain scalars. Plus, they also avoid the need to use things like docblocks for many = functions where merely adding types would make them self-explanatory. Thanks. -- Andrea Faulds http://ajf.me/