diff --git a/src/Latte/Runtime/CachingIterator.php b/src/Latte/Runtime/CachingIterator.php index 39ac77e3b7..191e1c572c 100644 --- a/src/Latte/Runtime/CachingIterator.php +++ b/src/Latte/Runtime/CachingIterator.php @@ -41,7 +41,7 @@ public function __construct($iterator) } elseif ($iterator instanceof \IteratorAggregate) { do { $iterator = $iterator->getIterator(); - } while ($iterator instanceof \IteratorAggregate); + } while (!$iterator instanceof \Iterator); } elseif ($iterator instanceof \Traversable) { if (!$iterator instanceof \Iterator) {