Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57016 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42102 invoked from network); 22 Dec 2011 19:18:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 19:18:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:60833] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/AC-12618-57283FE4 for ; Thu, 22 Dec 2011 14:18:13 -0500 Received: by qcsd16 with SMTP id d16so5556205qcs.29 for ; Thu, 22 Dec 2011 11:18:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=LOoov5pAK6hiPyu2PXZPSV11qgg64T1XEzUR4VWmsGw=; b=Ky9nihklQf3uDEEBOiHzAxx8UBFwpSFDdEKclY/n0+3sOjAz/iCT7hhQ2VjLT4v8s9 fgE3ti7G1ErgYa6+7Wln25F4jJY40/GnS3IBlzUBiPDb1xeuQ0R4h8U34j0LXT3KPBDz i61NjGEhU7prRWZqbeZGdnz4km4QBOYN+jC1o= Received: by 10.229.75.221 with SMTP id z29mr4631441qcj.128.1324581490919; Thu, 22 Dec 2011 11:18:10 -0800 (PST) Received: from [192.168.1.68] ([68.64.144.221]) by mx.google.com with ESMTPS id m20sm18982653qaj.14.2011.12.22.11.18.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Dec 2011 11:18:09 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: <4EF379D8.9000206@lerdorf.com> Date: Thu, 22 Dec 2011 14:18:04 -0500 Cc: Keloran , Dmitri Snytkine , Alain Williams , internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <3F793B30-19EA-4444-A976-C8CB3CAAD156@gmail.com> 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> To: Rasmus Lerdorf X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: will.fitch@gmail.com (Will Fitch) 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 >>=20 >> string, int >>=20 >> e.g. >> function int test(bool $tester) { >> if ($tester) { return 5; } >> return 99; >> } >=20 > 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. >=20 > if(age_check($_POST['age'])) { do_stuff(); } >=20 > because the author of the age_check() function added an int type hint > just doesn't make any sense. It would cause everyone to have to start > casting things everywhere, just in case. eg. >=20 > if(age_check((int)$_POST['age'])) { do_stuff(); } >=20 > This is not a step forward. If the author of age_check() really = doesn't > want to accept type-juggled arguments, then it is easy enough to do a > strict type check in the function itself. This puts the effort in the > correct place and doesn't encourage this type of coding. It absolutely isn't. I'm also against the class casting RFC which = would, in effect, do this very same thing. >=20 > -Rasmus >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20