Fix deprecation notice League/csv for createFromStream and createFromPath replaced by new from() method

This commit is contained in:
2025-10-27 13:21:04 +01:00
parent 01889ac671
commit f42bb498e4
15 changed files with 18 additions and 18 deletions

View File

@@ -334,7 +334,7 @@ class ChillImportUsersCommand extends Command
protected function loadUsers() protected function loadUsers()
{ {
$reader = Reader::createFromPath($this->tempInput->getArgument('csvfile')); $reader = Reader::from($this->tempInput->getArgument('csvfile'));
$reader->setHeaderOffset(0); $reader->setHeaderOffset(0);
foreach ($reader->getRecords() as $line => $r) { foreach ($reader->getRecords() as $line => $r) {
@@ -362,7 +362,7 @@ class ChillImportUsersCommand extends Command
protected function prepareGroupingCenters() protected function prepareGroupingCenters()
{ {
$reader = Reader::createFromPath($this->tempInput->getOption('grouping-centers')); $reader = Reader::from($this->tempInput->getOption('grouping-centers'));
$reader->setHeaderOffset(0); $reader->setHeaderOffset(0);
foreach ($reader->getRecords() as $r) { foreach ($reader->getRecords() as $r) {
@@ -378,7 +378,7 @@ class ChillImportUsersCommand extends Command
protected function prepareWriter() protected function prepareWriter()
{ {
$this->output = $output = Writer::createFromPath($this->tempInput $this->output = $output = Writer::from($this->tempInput
->getOption('csv-dump'), 'a+'); ->getOption('csv-dump'), 'a+');
$output->insertOne([ $output->insertOne([

View File

@@ -119,7 +119,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
protected function getReader() protected function getReader()
{ {
try { try {
$reader = Reader::createFromPath($this->input->getArgument('csvfile')); $reader = Reader::from($this->input->getArgument('csvfile'));
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('The csv file could not be read', [ $this->logger->error('The csv file could not be read', [
'path' => $this->input->getArgument('csvfile'), 'path' => $this->input->getArgument('csvfile'),

View File

@@ -43,7 +43,7 @@ final readonly class UserExportController
$users = $this->userRepository->findAllAsArray($request->getLocale()); $users = $this->userRepository->findAllAsArray($request->getLocale());
$csv = Writer::createFromPath('php://temp', 'r+'); $csv = Writer::from('php://temp', 'r+');
$csv->insertOne( $csv->insertOne(
array_map( array_map(
fn (string $e) => $this->translator->trans('admin.users.export.'.$e), fn (string $e) => $this->translator->trans('admin.users.export.'.$e),
@@ -104,7 +104,7 @@ final readonly class UserExportController
$userPermissions = $this->userRepository->findAllUserACLAsArray(); $userPermissions = $this->userRepository->findAllUserACLAsArray();
$csv = Writer::createFromPath('php://temp', 'r+'); $csv = Writer::from('php://temp', 'r+');
$csv->insertOne( $csv->insertOne(
array_map( array_map(
fn (string $e) => $this->translator->trans('admin.users.export.'.$e), fn (string $e) => $this->translator->trans('admin.users.export.'.$e),

View File

@@ -64,7 +64,7 @@ class AddressReferenceBEFromBestAddress
$uncompressedStream = gzopen($tmpname, 'r'); $uncompressedStream = gzopen($tmpname, 'r');
$csv = Reader::createFromStream($uncompressedStream); $csv = Reader::from($uncompressedStream);
$csv->setDelimiter(','); $csv->setDelimiter(',');
$csv->setHeaderOffset(0); $csv->setHeaderOffset(0);

View File

@@ -287,7 +287,7 @@ final class AddressReferenceBaseImporter
$filename = sprintf('%s-%s.csv', (new \DateTimeImmutable())->format('Ymd-His'), uniqid()); $filename = sprintf('%s-%s.csv', (new \DateTimeImmutable())->format('Ymd-His'), uniqid());
$path = Path::normalize(sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, $filename)); $path = Path::normalize(sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, $filename));
$writer = Writer::createFromPath($path, 'w+'); $writer = Writer::from($path, 'w+');
// insert headers // insert headers
$writer->insertOne([ $writer->insertOne([
'postalcode', 'postalcode',

View File

@@ -53,7 +53,7 @@ class AddressReferenceFromBAN
// re-open it to read it // re-open it to read it
$csvDecompressed = gzopen($path, 'r'); $csvDecompressed = gzopen($path, 'r');
$csv = Reader::createFromStream($csvDecompressed); $csv = Reader::from($csvDecompressed);
$csv->setDelimiter(';')->setHeaderOffset(0); $csv->setDelimiter(';')->setHeaderOffset(0);
$stmt = new Statement(); $stmt = new Statement();
$stmt = $stmt->process($csv, [ $stmt = $stmt->process($csv, [

View File

@@ -41,7 +41,7 @@ class AddressReferenceFromBano
fseek($file, 0); fseek($file, 0);
$csv = Reader::createFromStream($file); $csv = Reader::from($file);
$csv->setDelimiter(','); $csv->setDelimiter(',');
$stmt = new Statement(); $stmt = new Statement();
$stmt = $stmt->process($csv, [ $stmt = $stmt->process($csv, [

View File

@@ -39,7 +39,7 @@ class AddressReferenceLU
fseek($file, 0); fseek($file, 0);
$csv = Reader::createFromStream($file); $csv = Reader::from($file);
$csv->setDelimiter(';'); $csv->setDelimiter(';');
$csv->setHeaderOffset(0); $csv->setHeaderOffset(0);

View File

@@ -43,7 +43,7 @@ class PostalCodeBEFromBestAddress
$uncompressedStream = gzopen($tmpname, 'r'); $uncompressedStream = gzopen($tmpname, 'r');
$csv = Reader::createFromStream($uncompressedStream); $csv = Reader::from($uncompressedStream);
$csv->setDelimiter(','); $csv->setDelimiter(',');
$csv->setHeaderOffset(0); $csv->setHeaderOffset(0);

View File

@@ -47,7 +47,7 @@ class PostalCodeFRFromOpenData
fseek($tmpfile, 0); fseek($tmpfile, 0);
$csv = Reader::createFromStream($tmpfile); $csv = Reader::from($tmpfile);
$csv->setDelimiter(','); $csv->setDelimiter(',');
$csv->setHeaderOffset(0); $csv->setHeaderOffset(0);

View File

@@ -49,7 +49,7 @@ final class ImportSocialWorkMetadata extends Command
$filepath = $input->getOption('filepath'); $filepath = $input->getOption('filepath');
try { try {
$csv = Reader::createFromPath($filepath); $csv = Reader::from($filepath);
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw new \Exception('Error while loading CSV.', 0, $e); throw new \Exception('Error while loading CSV.', 0, $e);
} }

View File

@@ -29,7 +29,7 @@ class LoadSocialWorkMetadata extends Fixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
try { try {
$csv = Reader::createFromPath(__DIR__.'/data/social_work_metadata.csv'); $csv = Reader::from(__DIR__.'/data/social_work_metadata.csv');
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw new \Exception('Error while loading CSV.', 0, $e); throw new \Exception('Error while loading CSV.', 0, $e);
} }

View File

@@ -38,7 +38,7 @@ final readonly class SocialActionCSVExportService
array_keys($this->formatRow(new SocialAction())) array_keys($this->formatRow(new SocialAction()))
); );
$csv = Writer::createFromPath('php://temp', 'w+'); $csv = Writer::from('php://temp', 'w+');
$csv->insertOne($headers); $csv->insertOne($headers);
foreach ($actions as $action) { foreach ($actions as $action) {

View File

@@ -36,7 +36,7 @@ readonly class SocialIssueCSVExportService
public function generateCsv(array $issues): Writer public function generateCsv(array $issues): Writer
{ {
// CSV headers // CSV headers
$csv = Writer::createFromPath('php://temp', 'r+'); $csv = Writer::from('php://temp', 'r+');
$csv->insertOne( $csv->insertOne(
array_map( array_map(
fn (string $e) => $this->translator->trans($e), fn (string $e) => $this->translator->trans($e),

View File

@@ -52,7 +52,7 @@ class ThirdpartyCSVExportController extends AbstractController
fwrite($output, "\xEF\xBB\xBF"); fwrite($output, "\xEF\xBB\xBF");
// Create CSV writer // Create CSV writer
$csv = Writer::createFromStream($output); $csv = Writer::from($output);
// Write header row // Write header row
$header = array_map( $header = array_map(