Re: RFC: Type hinting revisited for PHP 5.3
| From: | Geoffrey Sneddon | Date: | Wed, 01 Jul 2009 19:59:13 +0000 |
| Subject: | Re: RFC: Type hinting revisited for PHP 5.3 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44600@lists.php.net to get a copy of this message | ||
On 1 Jul 2009, at 18:59, Ilia Alshanetsky wrote:
The main source of conflict appears to be that in some cases typical type hinting is just too strict for PHP's typeless nature (most people expect that "1" == 1, while int type hint would definitely reject string "1").To be fair, this is really my compliant, but: I think, for consistency, it should behaviour like zend_parse_parameters, hence not being overly strict, and should set the variable to it casted to the expected type. If it behaves differently to zend_parse_parameters then it'll be annoying that substr(), whose first parameter is a string, behaves differently to function foobar(string $what) when passed an int, for example. I'd expect: function foo(string $bar) { var_dump($bar); } foo(1234); To output: string(4) "1234" As this appears to be consistent with what internal functions that use zend_parse_parameters do. I don't want PHP to become any more inconsistent with itself than it already is. -- Geoffrey Sneddon <http://gsnedders.com/>