Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Translation] Remove deprecated escape parameter from CsvFileLoader #60925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,21 @@ Serializer
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead
* Remove the `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer` classes

Translation
-----------

* Remove the `$escape` parameter from `CsvFileLoader::setCsvControl()`

```diff
use Symfony\Component\Translation\Loader\CsvFileLoader;

$loader = new CsvFileLoader();

// Set CSV control characters including escape character
-$loader->setCsvControl(';', '"', '\\');
+$loader->setCsvControl(';', '"');
```

TwigBridge
----------

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Translation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

8.0
---

* Remove the `$escape` parameter from `CsvFileLoader::setCsvControl()`

7.3
---

Expand Down
15 changes: 3 additions & 12 deletions src/Symfony/Component/Translation/Loader/CsvFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class CsvFileLoader extends FileLoader
{
private string $delimiter = ';';
private string $enclosure = '"';
/**
* @deprecated since Symfony 7.2, to be removed in 8.0
*/
private string $escape = '';

protected function loadResource(string $resource): array
{
Expand All @@ -38,7 +34,7 @@ protected function loadResource(string $resource): array
}

$file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY);
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
$file->setCsvControl($this->delimiter, $this->enclosure, '');

foreach ($file as $data) {
if (false === $data) {
Expand All @@ -54,16 +50,11 @@ protected function loadResource(string $resource): array
}

/**
* Sets the delimiter, enclosure, and escape character for CSV.
* Sets the delimiter and enclosure character for CSV.
*/
public function setCsvControl(string $delimiter = ';', string $enclosure = '"', string $escape = ''): void
public function setCsvControl(string $delimiter = ';', string $enclosure = '"'): void
{
$this->delimiter = $delimiter;
$this->enclosure = $enclosure;
if ('' !== $escape) {
trigger_deprecation('symfony/translation', '7.2', 'The "escape" parameter of the "%s" method is deprecated. It will be removed in 8.0.', __METHOD__);
}

$this->escape = $escape;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,4 @@ public function testLoadNonLocalResource()
(new CsvFileLoader())->load('http://example.com/resources.csv', 'en', 'domain1');
}

/**
* @group legacy
*/
public function testEscapeCharInCsvControlIsDeprecated()
{
$loader = new CsvFileLoader();

$this->expectUserDeprecationMessage('Since symfony/translation 7.2: The "escape" parameter of the "Symfony\Component\Translation\Loader\CsvFileLoader::setCsvControl" method is deprecated. It will be removed in 8.0.');
$loader->setCsvControl(';', '"', '\\');
}
}
1 change: 0 additions & 1 deletion src/Symfony/Component/Translation/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
],
"require": {
"php": ">=8.4",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "^1.0",
"symfony/translation-contracts": "^2.5|^3.0"
},
Expand Down
Loading