Skip to content

Commit

Permalink
Revert "Prevent errors when the iterable is an already closed generat…
Browse files Browse the repository at this point in the history
…or."

Reasons: 43e4e43#r69609701

This reverts commit 43e4e43.
  • Loading branch information
drupol committed Mar 27, 2022
1 parent cf1232f commit e5690c7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
6 changes: 1 addition & 5 deletions src/IterableIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Generator;
use IteratorAggregate;
use Throwable;
use Traversable;

/**
Expand Down Expand Up @@ -40,9 +39,6 @@ public function __construct(iterable $iterable)
*/
public function getIterator(): Traversable
{
try {
yield from $this->iterable;
} catch (Throwable $exception) {
}
yield from $this->iterable;
}
}
15 changes: 0 additions & 15 deletions tests/unit/IterableIteratorAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,4 @@ public function testUseNext(): void

self::assertSame(2, $iterator->current());
}

public function testWithAClosedGenerator(): void
{
$generator = (static function () {
yield 'foo';

yield 'bar';
})();

iterator_to_array($generator);

$subject = (new IterableIteratorAggregate($generator))->getIterator();

self::assertSame([], iterator_to_array($subject));
}
}

0 comments on commit e5690c7

Please sign in to comment.