Skip to content

Commit 76792db

Browse files
Merge branch '5.4' into 6.4
* 5.4: [Filesystem] Fix Filesystem::remove() on Windows [DoctrineBridge] Fix compat with DI >= 6.4 [String] Fix *String::snake methods
2 parents f3c6aeb + 065a961 commit 76792db

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

AbstractUnicodeString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ public function reverse(): static
346346

347347
public function snake(): static
348348
{
349-
$str = $this->camel();
350-
$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');
349+
$str = clone $this;
350+
$str->string = str_replace(' ', '_', mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1 \2', $str->string), 'UTF-8'));
351351

352352
return $str;
353353
}

ByteString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ public function slice(int $start = 0, ?int $length = null): static
342342

343343
public function snake(): static
344344
{
345-
$str = $this->camel();
346-
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
345+
$str = clone $this;
346+
$str->string = str_replace(' ', '_', strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1 \2', $str->string)));
347347

348348
return $str;
349349
}

Tests/AbstractAsciiTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,8 @@ public static function provideSnake()
10751075
['symfony_is_great', 'symfonyIsGREAT'],
10761076
['symfony_is_really_great', 'symfonyIsREALLYGreat'],
10771077
['symfony', 'SYMFONY'],
1078+
['symfony_is_great', 'SYMFONY IS GREAT'],
1079+
['symfony_is_great', 'SYMFONY_IS_GREAT'],
10781080
];
10791081
}
10801082

0 commit comments

Comments
 (0)