Skip to content

Commit

Permalink
Revert "[8.x] Allow lazy collection to be instantiated from a generat…
Browse files Browse the repository at this point in the history
…or (#36738)" (#36844)

This reverts commit f75e510.
  • Loading branch information
driesvints committed Apr 1, 2021
1 parent d8a53a0 commit 343d9b4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
7 changes: 1 addition & 6 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use ArrayIterator;
use Closure;
use DateTimeInterface;
use Generator;
use Illuminate\Support\Traits\EnumeratesValues;
use Illuminate\Support\Traits\Macroable;
use IteratorAggregate;
Expand All @@ -30,7 +29,7 @@ class LazyCollection implements Enumerable
*/
public function __construct($source = null)
{
if ($source instanceof Closure || $source instanceof Generator || $source instanceof self) {
if ($source instanceof Closure || $source instanceof self) {
$this->source = $source;
} elseif (is_null($source)) {
$this->source = static::empty();
Expand Down Expand Up @@ -1365,10 +1364,6 @@ public function count()
*/
protected function makeIterator($source)
{
if ($source instanceof Generator) {
return $source;
}

if ($source instanceof IteratorAggregate) {
return $source->getIterator();
}
Expand Down
25 changes: 0 additions & 25 deletions tests/Support/SupportLazyCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,6 @@ public function testCanCreateCollectionFromClosure()
], $data->all());
}

public function testCanCreateCollectionFromGenerator()
{
$iterable = function () {
yield 1;
yield 2;
yield 3;
};
$data = LazyCollection::make($iterable());

$this->assertSame([1, 2, 3], $data->all());

$iterable = function () {
yield 'a' => 1;
yield 'b' => 2;
yield 'c' => 3;
};
$data = LazyCollection::make($iterable());

$this->assertSame([
'a' => 1,
'b' => 2,
'c' => 3,
], $data->all());
}

public function testEager()
{
$source = [1, 2, 3, 4, 5];
Expand Down

0 comments on commit 343d9b4

Please sign in to comment.