Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75467 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96052 invoked from network); 14 Jul 2014 14:54:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 14:54:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:42336] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/E0-25444-C0FE3C35 for ; Mon, 14 Jul 2014 10:54:05 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id E93DD10C053; Mon, 14 Jul 2014 15:54:01 +0100 (BST) Date: Mon, 14 Jul 2014 15:54:01 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Andrea Faulds cc: PHP internals In-Reply-To: Message-ID: References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-1456456383-1405349641=:4247" Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: derick@php.net (Derick Rethans) --8323329-1456456383-1405349641=:4247 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 14 Jul 2014, Andrea Faulds wrote: >=20 > On 14 Jul 2014, at 15:38, Derick Rethans wrote: >=20 > > I am worried about this big casting conversion matrix. New rules should= =20 > > not be invented, and the following should *always* be equivalent: > >=20 > > =09function foo(typehint $var) > >=20 > > vs: > >=20 > > =09function foo($var) { > > =09=09$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. >=20 > I=E2=80=99ve talked about this before in this thread, but the justificati= on=20 > for differing in behaviour from array and class hints is that these=20 > types are scalars (which PHP routinely juggles) and arrays and objects=20 > are not scalar (and not routinely juggled). While we are indeed=20 > casting, we=E2=80=99re only doing so where the conversion would be lossle= ss.=20 > Sure, it=E2=80=99s not a hard check, but it is still quite strict. I don= =E2=80=99t=20 > like the idea of completely strict type hints here, but I also don=E2=80= =99t=20 > think that completely loose type hints that cast and do zero=20 > validation are for the best either. This RFC tries to strike a=20 > compromise. A compromise by adding more inconsistencies. I can buy the cast of scalars vs hint--of-complex types, but definitely=20 not the introduction of a new group of casting rules. Keep it simple. cheers, Derick --=20 http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine --8323329-1456456383-1405349641=:4247--