-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Description
Symfony version(s) affected
7.2
Description
CsvEncoder accepts iterator to encode
function, but it doesn't work properly with Traversable or any non-simple-array iterators
How to reproduce
class Example
{
public function build()
{
$encoder = new CsvEncoder();
$csv = $encoder->encode($this->getLineIterator(), CsvEncoder::FORMAT);
}
private function getLineIterator(): Traversable
{
for ($i=0;$i< 1000; $i++) {
yield [(string) $i];
}
}
}
I get an exception
Cannot traverse an already closed generator
Possible Solution
No response
Additional Context
No response