On Thu, Jul 16, 2015 at 4:38 AM, Michael Wallner <m...@php.net> wrote:
> On 16/07/15 11:26, Rowan Collins wrote:
>> Benjamin Eberlei wrote on 15/07/2015 21:19:
>>>
>>> But instanceof and anything related to Reflection or get_class or
>>> relevant code will fail on array.
>>
>>
>> Ah, yes, I hadn't thought of reflection type things. I don't think
>> instanceof would be a problem, because checking for any class or
>> interface other than Traversable would correctly return false; not sure
>> if it would make sense for "array() instanceof Traversable" to return
>> true or not...
>>
>
> Maybe some pseudotype like callable (e.g. iteratable) makes more sense then?

People have talked about creating types like so:

type Iterable = array | Traversable;

which could then be used as normal:

function foo(Iterable $f);

I understand that this is the second feature I have mentioned in this
train of thought that has not yet be officially proposed, but I think
it's relevant. Why special case a pseudo-type if we can have a generic
way of making them in user-land?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to