diff --git a/src/Language/AST/NodeList.php b/src/Language/AST/NodeList.php index cede5a4..c91fbcf 100644 --- a/src/Language/AST/NodeList.php +++ b/src/Language/AST/NodeList.php @@ -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); } }