Skip to content

Commit 4364734

Browse files
[String] Fix camel() method with unicode string
1 parent 3b4cbfe commit 4364734

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function ascii(array $rules = []): self
162162
public function camel(): parent
163163
{
164164
$str = clone $this;
165-
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) use (&$i) {
165+
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function ($m) use (&$i) {
166166
return 1 === ++$i ? ('İ' === $m[0] ? '' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
167167
}, preg_replace('/[^\pL0-9]++/u', ' ', $this->string)));
168168

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,7 @@ public static function provideCamel()
10461046
['symfonyIsGreat', 'symfony_is_great'],
10471047
['symfony5IsGreat', 'symfony_5_is_great'],
10481048
['symfonyIsGreat', 'Symfony is great'],
1049+
['SYMFONYISGREAT', 'SYMFONY_IS_GREAT'],
10491050
['symfonyIsAGreatFramework', 'Symfony is a great framework'],
10501051
['symfonyIsGREAT', '*Symfony* is GREAT!!'],
10511052
['SYMFONY', 'SYMFONY'],
@@ -1077,12 +1078,12 @@ public static function provideSnake()
10771078
['symfony_is_great', 'symfonyIsGREAT'],
10781079
['symfony_is_really_great', 'symfonyIsREALLYGreat'],
10791080
['symfony', 'SYMFONY'],
1080-
['symfony_is_great', 'SYMFONY IS GREAT'],
1081-
['symfony_is_great', 'SYMFONY_IS_GREAT'],
1081+
['symfonyisgreat', 'SYMFONY IS GREAT'],
1082+
['symfonyisgreat', 'SYMFONY_IS_GREAT'],
10821083
['symfony_is_great', 'symfony is great'],
1083-
['symfony_is_great', 'SYMFONY IS GREAT'],
1084-
['symfony_is_great', 'SYMFONY _ IS _ GREAT'],
1085-
['symfony_is_great', 'Symfony IS GREAT!'],
1084+
['symfonyisgreat', 'SYMFONY IS GREAT'],
1085+
['symfonyisgreat', 'SYMFONY _ IS _ GREAT'],
1086+
['symfony_isgreat', 'Symfony IS GREAT!'],
10861087
];
10871088
}
10881089

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy