Description
Symfony version(s) affected
6.2.0
Description
When you try tu use empty enclosure the serialization fail
How to reproduce
`require DIR.'/../vendor/autoload.php';
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$encoders = [new JsonEncoder(), new CsvEncoder()];
$normalizers = [new ObjectNormalizer($classMetadataFactory)];
$serializer = new Serializer($normalizers, $encoders);
$context = [CsvEncoder::ENCLOSURE_KEY => ''];
$json = $serializer->serialize(
new Foo(bar: 'bar value', baz: 'baz value', buzz: 'buz value'),
format: 'csv',
context: $context
);`
Possible Solution
When we serialize we can check if the enclosure is empty.
If the enclosure is empty call the method fputcsv with the default enclosure
use str_replace to remplace the default enclosure by empty string
write the file with the string changed
Additional Context
No response