From e5b955ecc86b91cd9a82ab9d6452a8881c069059 Mon Sep 17 00:00:00 2001 From: spawnia Date: Thu, 9 May 2019 17:04:17 +0200 Subject: [PATCH] Use array_keys for iterating over NodeList --- src/Language/AST/NodeList.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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); } }