Re: Type hinting - Request for Discussion
| From: | Lewis Wright | Date: | Fri, 10 Jul 2009 10:51:10 +0000 |
| Subject: | Re: Type hinting - Request for Discussion | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44897@lists.php.net to get a copy of this message | ||
2009/7/10 Ionut G. Stan <ionut.g.stan@gmail.com>
> On 7/10/2009 13:23, Giovanni Giacobbi wrote:
>
>> On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote:
>> [...]
>>
>>
>>> For example, instead of:
>>>
>>> function addFive(int $x) {
>>> return $x + 5;
>>> }
>>>
>>> You would simply do:
>>>
>>> function addFive(is_numeric $x) {
>>> return $x + 5;
>>> }
>>>
>>> Since $x is guaranteed to be numeric, it is safe to to arithmetic on
>>> it. No reason to explicitly type cast here.
>>>
>>>
>>>
>> I like it too. Not only it solves the initial problem, but it also allows
> userland extensions. For example,
> the current patch does not provide checks for callables, but we already
> have is_callable in the core.
But isn't is_numeric still a valid class name? Would that mean that classes
could no longer be called is_*?