Merge pull request #475 from mll-lab/nodelist-offsets

Use foreach for iterating over NodeList
This commit is contained in:
Vladimir Razuvaev 2019-05-10 11:57:44 +07:00 committed by GitHub
commit 22e3b0e981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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