Re: Return type hinting patch
| From: | David Zülke | Date: | Sat, 26 Apr 2008 23:26:24 +0000 |
| Subject: | Re: Return type hinting patch | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37255@lists.php.net to get a copy of this message | ||
Am 27.04.2008 um 00:24 schrieb Nathan Nobbe:
On Sat, Apr 26, 2008 at 2:06 PM, David Zülke <dz@bitxtender.com> wrote:Well that was my point. Functions without return type hints use "function", to indicate that they are generic in this respect, and functions/methods with a type hint omit it to signal the difference. Having both would be redundant. But then...:Wouldn't the most consistent way be to omit "function" altogether when using a return type hint? public static function zomg() { return $somethingArbitrary; } public static string foo() { return $mustBeString; }i think leaving 'function' in there makes sense because thats the way php currently works.
Absolutely not. Right now, all PHP native types are lowercase. Can't see why anon functions should be different. Actually, both ways have problems: public function gimmeThat() { return function() { echo 'yay'; } } is ambiguous if return type hints require omitting "function", and public function function gimmeThat() { ... } is just plain ugly. So maybe anon funcs should have a different type name :p Davidotoh, should there ever be a type "function" (e.g. for anonymous funcs) down the road, that'd mean trouble ;)wow; good point! maybe if anonymous functions are ever supported the type could be capitalized as in 'Function' public function Function doStuff() { return function() {} }