File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 5
5
use ArrayIterator ;
6
6
use Closure ;
7
7
use DateTimeInterface ;
8
+ use Generator ;
8
9
use Illuminate \Support \Traits \EnumeratesValues ;
9
10
use Illuminate \Support \Traits \Macroable ;
10
11
use IteratorAggregate ;
@@ -29,7 +30,7 @@ class LazyCollection implements Enumerable
29
30
*/
30
31
public function __construct ($ source = null )
31
32
{
32
- if ($ source instanceof Closure || $ source instanceof self) {
33
+ if ($ source instanceof Closure || $ source instanceof Generator || $ source instanceof self) {
33
34
$ this ->source = $ source ;
34
35
} elseif (is_null ($ source )) {
35
36
$ this ->source = static ::empty ();
@@ -1364,6 +1365,10 @@ public function count()
1364
1365
*/
1365
1366
protected function makeIterator ($ source )
1366
1367
{
1368
+ if ($ source instanceof Generator) {
1369
+ return $ source ;
1370
+ }
1371
+
1367
1372
if ($ source instanceof IteratorAggregate) {
1368
1373
return $ source ->getIterator ();
1369
1374
}
You can’t perform that action at this time.
0 commit comments