Skip to content

Commit c656ad1

Browse files
bug symfony#54888 [String] Fix folded in compat mode (smnandre)
This PR was submitted for the 6.4 branch but it was squashed and merged into the 5.4 branch instead. Discussion ---------- [String] Fix folded in compat mode | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT (Spotted by PHPStorm) Both those lines of code were setting `$str->string` value, the second line cancelling any effect of the first. ```php $str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC); $str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $this->string), 'UTF-8'); ``` Did not know if i had to add tests, as the `$compat` argument is not really defined in the interface... and seems unused in the codebase 🤷‍♂️ (It also took me a bit of time to realize the `dataProvider` problem 😮‍💨 ) Commits ------- 37e98c7 [String] Fix folded in compat mode
2 parents ac30c7e + 37e98c7 commit c656ad1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function folded(bool $compat = true): parent
195195

196196
if (!$compat || \PHP_VERSION_ID < 70300 || !\defined('Normalizer::NFKC_CF')) {
197197
$str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC);
198-
$str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $this->string), 'UTF-8');
198+
$str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $str->string), 'UTF-8');
199199
} else {
200200
$str->string = normalizer_normalize($str->string, \Normalizer::NFKC_CF);
201201
}

src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,10 @@ public static function provideBeforeAfterLastIgnoreCase(): array
470470
);
471471
}
472472

473-
public static function provideToFoldedCase(): array
473+
public static function provideFolded(): array
474474
{
475475
return array_merge(
476-
parent::provideToFoldedCase(),
476+
parent::provideFolded(),
477477
[
478478
['déjà', 'DéjÀ'],
479479
['σσσ', 'Σσς'],

0 commit comments

Comments
 (0)