Re: Return type hints
| From: | Christian Schneider | Date: | Mon, 07 Apr 2008 17:12:13 +0000 |
| Subject: | Re: Return type hints | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-36853@lists.php.net to get a copy of this message | ||
Stanislav Malyshev wrote:
> I'm not sure I understand - how array_reduce is related to having type
> hints? You could make array_reduce to do additional things, but that
> doesn't require introducing strong typing into php.
The relation between array_reduce and scalar type hints is that API
start to enforce certain types where they should not just because the
programmer thinks it is a good idea.
Currently the third parameter $initial of array_reduce only allows int.
So instead of allowing any zval and leaving it to the callback function
to deal with it a specific type is enforced. You can work around this by
checking for NULL inside the callback and initializing it there but that
does not work either if you use a built-in function as callback.
- Chris