Skip to content

Commit

Permalink
fixed types in csv import
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Mar 26, 2024
1 parent 224cf84 commit 70f15d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Application/CsvParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace kissj\Application;

use Iterator;
use League\Csv\Exception as LeagueCsvException;
use League\Csv\Reader;
use Psr\Http\Message\StreamInterface;
Expand All @@ -15,9 +16,8 @@ class CsvParser
/**
* @throws UnexpectedValueException
* @throws LeagueCsvException
* @return array<array<string,string>>
*/
public function parseCsv(UploadedFile $file): array
public function parseCsv(UploadedFile $file): Iterator
{
/** @var StreamInterface|null $stream */
$stream = $file->getStream();
Expand All @@ -28,9 +28,6 @@ public function parseCsv(UploadedFile $file): array
$csv = Reader::createFromString($stream->getContents());
$csv->setHeaderOffset(0);

/** @var array<array<string,string>> $records */
$records = $csv->getRecords();

return $records;
return $csv->getRecords();
}
}
1 change: 1 addition & 0 deletions src/Import/ImportSrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function importIst(UploadedFile $istsDataFile, Event $event): void
{
$istsData = [];
try {
/** @var array<array<string,string>> $istsData */
$istsData = $this->csvParser->parseCsv($istsDataFile);
} catch (\UnexpectedValueException | LeagueCsvException) {
$this->flashMessages->error($this->translator->trans('flash.error.importSrs.invalidCsv'));
Expand Down

0 comments on commit 70f15d8

Please sign in to comment.