Re: Return Type Hinting for Methods RFC

From: Date: Thu, 22 Dec 2011 19:19:52 +0000
Subject: Re: Return Type Hinting for Methods RFC
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-57018@lists.php.net to get a copy of this message
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

« previous php.internals (#57018) next »