php-ds / ext-ds

An extension providing efficient data structures for PHP 7
https://medium.com/p/9dda7af674cd
MIT License
2.11k stars 95 forks source link

Implement IteratorAggregate instead of Traversable #166

Closed enumag closed 2 years ago

enumag commented 4 years ago

In PHP 8 changelog you can find a bunch of changes like:

- Date:
  . DatePeriod now implements IteratorAggregate (instead of Traversable).

- DOM:
  . DOMNamedNodeMap now implements IteratorAggregate (instead of Traversable).
  . DOMNodeList now implements IteratorAggregate (instead of Traversable).

- Intl:
  . IntlBreakIterator now implements IteratorAggregate (instead of Traversable).
  . ResourceBundle now implements IteratorAggregate (instead of Traversable).

It would be nice if ext-ds did the same for consistency. It's quite confusing that the classes are Traversable without implementing Iterator or IteratorAggregate (not possible in PHP code). And also it complicates some usages such as using AppendIterator since it doesn't accept Traversable. Also it creates a difference from the polyfill.

rtheunissen commented 2 years ago

See #170, I think this is done?

enumag commented 2 years ago

Nice! Thank you!