Pergunta

I am trying to understand something about ArrayObject and ArrayIterator classes

ArrayObject: This class implements the IteratorAggregate and Traversable interfaces. Since IteratorAggregate extends Traversable itself, why does ArrayObject implement both when it can just implement IteratorAggregate?

ArrayIterator: As above, this class implements both Iterator and Traversable which Iterator extends.

Why do these classes implement two interfaces when they could get away with implementing the one that extends Traversable?

Foi útil?

Solução

According to the SPL source code, ArrayObject doesn't implement Traversable directly:

class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
{
    ...
}

This matches the SPL documentation. I believe DaveRandom is correct.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top