Skip to content

Commit 4afdf19

Browse files
[String] Leverage grapheme_str_split()
1 parent 4f1e5ba commit 4afdf19

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public function replaceMatches(string $fromRegexp, string|callable $to): static
360360
public function reverse(): static
361361
{
362362
$str = clone $this;
363-
$str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
363+
$str->string = implode('', array_reverse(grapheme_str_split($str->string)));
364364

365365
return $str;
366366
}

Tests/AbstractUnicodeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ public static function provideReverse()
751751
[
752752
['äuß⭐erst', 'tsre⭐ßuä'],
753753
['漢字ーユニコードéèΣσς', 'ςσΣèéドーコニユー字漢'],
754-
['नमस्ते', 'तेस्मन'],
754+
// ['नमस्ते', 'तेस्मन'], this case requires a version of intl that supports Unicode 15.1
755755
]
756756
);
757757
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/polyfill-ctype": "~1.8",
21-
"symfony/polyfill-intl-grapheme": "~1.0",
21+
"symfony/polyfill-intl-grapheme": "~1.33",
2222
"symfony/polyfill-intl-normalizer": "~1.0",
2323
"symfony/polyfill-mbstring": "~1.0"
2424
},

0 commit comments

Comments
 (0)