Re: Return type hints
| From: | Christian Schneider | Date: | Mon, 14 Apr 2008 14:28:28 +0000 |
| Subject: | Re: Return type hints | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37002@lists.php.net to get a copy of this message | ||
Chris Stockton schrieb:
Why on earth would you have int, string, resource, etc "return type hints" and then turn around and suggest for parameter hinting just add a scalar type? That makes no sense and is so inconsistent. static int function retarded(scalar $value) {Let me turn your question around: Why on earth would someone restrict a function to int when string works just as well? function int foo_flexible(scalar $x) { return $x + 42; } $foo = foo_flexible($value); function int foo_retarded(int $x) { return $x + 42; } $foo = foo_retarded((int)$value); # :-( That said, I'll be using function foo($x) { return $x + 42; } anyway and let PHP warnings take care of the rest ;-) - Chrisreturn (int) $value; // lol....}