Skip to content

Commit f6ca040

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [String] Fix snake conversion [DowCrawler] Fix locale-sensitivity of whitespace normalization suggest to install the Twig bundle when the required component is already installed Update PULL_REQUEST_TEMPLATE.md [Serializer] Fix throwing right exception in ArrayDenormalizer with invalid type
2 parents efb8110 + e4d0e8e commit f6ca040

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

AbstractString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ abstract public function chunk(int $length = 1): array;
244244
public function collapseWhitespace(): static
245245
{
246246
$str = clone $this;
247-
$str->string = trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $str->string));
247+
$str->string = trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $str->string), " \n\r\t\x0C");
248248

249249
return $str;
250250
}

AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function reverse(): static
356356

357357
public function snake(): static
358358
{
359-
$str = $this->camel()->title();
359+
$str = $this->camel();
360360
$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');
361361

362362
return $str;

ByteString.php

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

348348
public function snake(): static
349349
{
350-
$str = $this->camel()->title();
350+
$str = $this->camel();
351351
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
352352

353353
return $str;

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)