8000 [String] Fix snake conversion · symfony/symfony@1416dbc · GitHub
[go: up one dir, main page]

Skip to content

Commit 1416dbc

Browse files
committed
[String] Fix snake conversion
1 parent 614a575 commit 1416dbc

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function reverse(): parent
366366

367367
public function snake(): parent
368368
{
369-
$str = $this->camel()->title();
369+
$str = $this->camel();
370370
$str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8');
371371

372372
return $str;

src/Symfony/Component/String/ByteString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public function slice(int $start = 0, int $length = null): parent
363363

364364
public function snake(): parent
365365
{
366-
$str = $this->camel()->title();
366+
$str = $this->camel();
367367
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
368368

369369
return $str;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ public static function provideCamel()
10411041
{
10421042
return [
10431043
['', ''],
1044+
['xY', 'x_y'],
10441045
['symfonyIsGreat', 'symfony_is_great'],
10451046
['symfony5IsGreat', 'symfony_5_is_great'],
10461047
['symfonyIsGreat', 'Symfony is great'],
@@ -1063,6 +1064,8 @@ public static function provideSnake()
10631064
{
10641065
return [
10651066
['', ''],
1067+
['x_y', 'x_y'],
1068+
['x_y', 'X_Y'],
10661069
['symfony_is_great', 'symfonyIsGreat'],
10671070
['symfony5_is_great', 'symfony5IsGreat'],
10681071
['symfony5is_great', 'symfony5isGreat'],

0 commit comments

Comments
 (0)
0