Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57018 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44566 invoked from network); 22 Dec 2011 19:19:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 19:19:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.161.170 mail-gx0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:51092] helo=mail-gx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/4D-12618-DD283FE4 for ; Thu, 22 Dec 2011 14:19:57 -0500 Received: by ggnv1 with SMTP id v1so7006042ggn.29 for ; Thu, 22 Dec 2011 11:19:55 -0800 (PST) Received: by 10.50.45.195 with SMTP id p3mr10060389igm.2.1324581595244; Thu, 22 Dec 2011 11:19:55 -0800 (PST) Received: from [192.168.200.5] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPS id l28sm32018873ibc.3.2011.12.22.11.19.53 (version=SSLv3 cipher=OTHER); Thu, 22 Dec 2011 11:19:54 -0800 (PST) Message-ID: <4EF382D8.3050708@lerdorf.com> Date: Thu, 22 Dec 2011 11:19:52 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: Will Fitch CC: Keloran , Dmitri Snytkine , Alain Williams , internals@lists.php.net References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <005701ccc0b3$58c8dee0$0a5a9ca0$@alliantinternet.com> <20111222145159.GY25857@alliantinternet.com> <006101ccc0ba$46b81160$d4283420$@alliantinternet.com> <4EF379D8.9000206@lerdorf.com> <3F793B30-19EA-4444-A976-C8CB3CAAD156@gmail.com> In-Reply-To: <3F793B30-19EA-4444-A976-C8CB3CAAD156@gmail.com> X-Enigmail-Version: 1.4a1pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: rasmus@lerdorf.com (Rasmus Lerdorf) On 12/22/2011 11:18 AM, Will Fitch wrote: > On Dec 22, 2011, at 1:41 PM, Rasmus Lerdorf wrote: > >> On 12/22/2011 07:08 AM, Keloran wrote: >>> i would love to see this expanded aswell (the way type hinting on function >>> variables was supposed to be), so that it could be >>> >>> string, int >>> >>> e.g. >>> function int test(bool $tester) { >>> if ($tester) { return 5; } >>> return 99; >>> } >> >> Return type hinting needs to be aligned with parameter type hinting, and >> as has been pointed out many times on this list, type hinting for >> interchangable scalar types is a really bad idea. It will push all type >> checking up to the caller of the underlying functions/methods. PHP is >> primarily a Web scripting language and the Web isn't typed. Having stuff >> like this break: > > Have you taken a look at the RFC and/or patch? This functionality is exactly aligned with parameter type hinting. Only classes, arrays and callables are allowed types. I agree 100% on scalars. Yes, I know, but any talk about typing invariable brings the strong typing scalars proponents out of the woodwork. -Rasmus