Re: Type hinting
| From: | Sebastian Bergmann | Date: | Fri, 28 May 2010 10:18:57 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48550@lists.php.net to get a copy of this message | ||
Am 27.05.2010 00:30, schrieb Derick Rethans:
+1 -- Sebastian Bergmann Co-Founder and Principal Consultant http://sebastian-bergmann.de/ http://thePHP.cc/Would it be possible to support two syntaxes: function foo( (int) $bar) { } // auto-cast to intI think that's a brilliant plan. We won't ever agree on whether we want either strict type hinting, or casting typehinting and this provides both possibilities with the following pros: - The syntax is consistent for casting. We already support (int) $bar anywhere else. - The syntax is consistent for strict type checking. We already support throwing errors with foo(ClassName $bar). - There are no new conversion rules that can confuse people. - Type checking with "int $bar" will stay fast, as we only have to compare type.function foo(int $bar) { } // require int