Use array_keys for iterating over NodeList

This commit is contained in:
spawnia 2019-05-09 17:04:17 +02:00
parent 49b7aced87
commit e5b955ecc8

View File

@ -114,9 +114,8 @@ class NodeList implements ArrayAccess, IteratorAggregate, Countable
*/
public function getIterator()
{
$count = count($this->nodes);
for ($i = 0; $i < $count; $i++) {
yield $this->offsetGet($i);
foreach (array_keys($this->nodes) as $key) {
yield $this->offsetGet($key);
}
}