Skip to content
This repository was archived by the owner on Dec 28, 2023. It is now read-only.

Commit 1b3dd0b

Browse files
committed
Iterators: Fix infinite loop
1 parent 40e3f59 commit 1b3dd0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Utils/Iterators.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function toArray($src)
4141
if (is_array($src)) {
4242
return $src;
4343
}
44-
while ($src instanceof \IteratorAggregate) {
44+
if ($src instanceof \IteratorAggregate) {
4545
$src = $src->getIterator();
4646
}
4747
if ($src instanceof \ArrayIterator) {
@@ -76,7 +76,7 @@ public static function toList($src)
7676
if (is_array($src)) {
7777
return array_values($src);
7878
}
79-
while ($src instanceof \IteratorAggregate) {
79+
if ($src instanceof \IteratorAggregate) {
8080
$src = $src->getIterator();
8181
}
8282
if ($src instanceof \ArrayIterator) {
@@ -111,7 +111,7 @@ public static function count($src)
111111
if (is_array($src)) {
112112
return count($src);
113113
}
114-
while ($src instanceof \IteratorAggregate) {
114+
if ($src instanceof \IteratorAggregate) {
115115
$src = $src->getIterator();
116116
}
117117
if ($src instanceof \Countable) {
@@ -134,7 +134,7 @@ public static function isEmpty($src)
134134
if (is_array($src)) {
135135
return empty($src);
136136
}
137-
while ($src instanceof \IteratorAggregate) {
137+
if ($src instanceof \IteratorAggregate) {
138138
$src = $src->getIterator();
139139
}
140140
if ($src instanceof \Countable) {

0 commit comments

Comments
 (0)