Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75466 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94298 invoked from network); 14 Jul 2014 14:44:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 14:44:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; 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:46861] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/80-25444-DDCE3C35 for ; Mon, 14 Jul 2014 10:44:46 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 829CBB00087; Mon, 14 Jul 2014 10:44:43 -0400 (EDT) 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 R5fvdYxyB-Hq; Mon, 14 Jul 2014 10:44:43 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 853AEB0008A; Mon, 14 Jul 2014 10:44:42 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Mon, 14 Jul 2014 15:44:38 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> To: Derick Rethans X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: ajf@ajf.me (Andrea Faulds) On 14 Jul 2014, at 15:38, Derick Rethans wrote: > I am worried about this big casting conversion matrix. New rules = should=20 > not be invented, and the following should *always* be equivalent: >=20 > function foo(typehint $var) >=20 > vs: >=20 > function foo($var) { > $var =3D typehint $var; >=20 > In general, I am not in favour of casting typehints, as it would be a=20= > different behaviour from the hard-check typehints that we already have=20= > for classes and arrays. I=92ve talked about this before in this thread, but the justification = for differing in behaviour from array and class hints is that these = types are scalars (which PHP routinely juggles) and arrays and objects = are not scalar (and not routinely juggled). While we are indeed casting, = we=92re only doing so where the conversion would be lossless. Sure, it=92s= not a hard check, but it is still quite strict. I don=92t like the idea = of completely strict type hints here, but I also don=92t think that = completely loose type hints that cast and do zero validation are for the = best either. This RFC tries to strike a compromise. -- Andrea Faulds http://ajf.me/