Skip to content

Commit ef8914f

Browse files
committed
[String] Fix snake conversion
1 parent 0145442 commit ef8914f

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

AbstractUnicodeString.php

+1-1
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;

ByteString.php

+1-1
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;

Tests/AbstractAsciiTestCase.php

+3
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)