Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82624 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48493 invoked from network); 13 Feb 2015 16:59:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2015 16:59:57 -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.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:35168] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/91-40724-A8D2ED45 for ; Fri, 13 Feb 2015 11:59:56 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 9003AB00093; Fri, 13 Feb 2015 11:59:50 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1VPUMz4AmJgc; Fri, 13 Feb 2015 11:59:50 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 25BB4B0008E; Fri, 13 Feb 2015 11:59:48 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Fri, 13 Feb 2015 16:59:46 +0000 Cc: Zeev Suraski , Rasmus Lerdorf , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> <54DAF884.7000508@lerdorf.com> <203e611c8e0b03568a868b8d931aec37@mail.gmail.com> To: Benjamin Eberlei X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints From: ajf@ajf.me (Andrea Faulds) Hi,=20 > On 13 Feb 2015, at 16:18, Benjamin Eberlei = wrote: >=20 > Wait i almost forgot, it *does* have an effect on me, especially = around callback handling: >=20 > https://gist.github.com/schmittjoh/778e044deacc6f1fe516=20 >=20 > Essentially callbacks are evaluated in the mode they are called in, = not in the one they are defined. This is correct, yes. This is only going to cause a problem, however, = if: * You add type hints despite not knowing what types will be passed * You add type hints for the wrong types In both cases, you have only yourself to blame for your code not = working. So, I really don=E2=80=99t think it=E2=80=99s an issue. If you = don=E2=80=99t know what types will be passed, why did you add type = hints? If you know what types will be passed and added incorrect type = hints, why did you expect that to always work? There is of course a third case: the function=E2=80=99s documentation = lies and claims the function will call your callback with certain types, = and actually passes different types. However, this is not a problem with = the RFC, and is something that could happen anyway. At least with this = RFC, you might discover the bug in the library more quickly due to = getting an error. Anyhow, we could catch such errors prior to call-time by extending the = callable typehint to take a parameter list, such that parameter type = hints can be checked (with the same rules as used by inheritance). This = would solve your problem. Thanks. -- Andrea Faulds http://ajf.me/