Skip to content

Commit

Permalink
Set empty string as escape character for CSVs to avoid deprecation wa…
Browse files Browse the repository at this point in the history
…rnings in PHP 8.4
  • Loading branch information
acelaya committed Aug 26, 2024
2 parents 6c813ad + ef968e5 commit 7c01f8c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this

### Changed
* Update dependencies.
* Set empty string as escape character for CSVs to avoid deprecation warnings in PHP 8.4

### Deprecated
* *Nothing*
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"guzzlehttp/guzzle": "^7.9",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^1.4",
"phpunit/phpunit": "^11.2",
"phpunit/phpunit": "^11.3",
"psr/http-factory": "^1.1",
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.3.0",
Expand Down Expand Up @@ -53,7 +53,7 @@
"cs": "phpcs",
"cs:fix": "phpcbf",
"stan": "phpstan analyse",
"test": "phpunit --order-by=random --testdox --colors=always",
"test": "phpunit --order-by=random --testdox --testdox-summary",
"test:ci": "@test --coverage-clover=build/clover.xml",
"test:pretty": "@test --coverage-html=build/coverage-html"
},
Expand Down
4 changes: 4 additions & 0 deletions src/Sources/Csv/CsvImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ private function importShortUrls(CsvParams $params): iterable
$csvReader = Reader::createFromStream($params->stream)->setDelimiter($params->delimiter)
->setHeaderOffset(0);

// FIXME Workaround for PHP 8.4 deprecation warnings. To remove with league/csv 10
// See https://github.com/thephpleague/csv/issues/532 for details
$csvReader->setEscape('');

foreach ($csvReader as $record) {
$record = $this->remapRecordHeaders($record);
[$shortCode, $domain] = $this->parseShortCodeAndDomain($record);
Expand Down

0 comments on commit 7c01f8c

Please sign in to comment.