Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80449 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59232 invoked from network); 14 Jan 2015 09:32:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2015 09:32:50 -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:41688] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/42-43840-1C736B45 for ; Wed, 14 Jan 2015 04:32:50 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id C98458C0069; Wed, 14 Jan 2015 04:32:46 -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 Ql6xTvSlJsGy; Wed, 14 Jan 2015 04:32:46 -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 B18FC8C0009; Wed, 14 Jan 2015 04:32:45 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Wed, 14 Jan 2015 09:32:42 +0000 Cc: PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> To: Leigh X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: ajf@ajf.me (Andrea Faulds) Hi Leigh, > On 14 Jan 2015, at 09:17, Leigh wrote: >=20 > I really don't like this behaviour being changed at the call site. If > I design a function that I _know_ should only take a string, then I > want it to be an error if the user supplies anything else, so that > they know they messed up. I don=E2=80=99t like the idea of being forced to use strict (or weak) = type checking because the API author decided as much. More importantly, having the function and not its caller decide makes = the addition of type hints to existing code difficult, because it will = (possibly unintentionally) rely on PHP=E2=80=99s weak typing and thus = error when faced with a strict type check. On the other hand, having the = callee decide means that you can relatively safely add type hints to = existing code and its consumers will not error. You can then gradually = migrate that consuming code over to strict type-checking, if you so = wish. > Also, there's this, that you might be able to re-purpose. > https://github.com/php/php-src/blob/d5dd29/Zend/zend_compile.c#L7199 I don=E2=80=99t want to get rid of that easter egg, and I prefer the = declare() syntax since it=E2=80=99s more obviously some sort of = directive (use strict; looks like an innocuous use statement) and = supports the block syntax. -- Andrea Faulds http://ajf.me/