Skip to content

Commit 8bcb635

Browse files
replace ucfirst with AbstractString::title()
1 parent fa52f7b commit 8bcb635

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

src/Symfony/Component/String/AbstractString.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,7 @@ public function kebab(): static
440440

441441
public function pascal(): static
442442
{
443-
$this->string = ucfirst($this->camel());
444-
445-
return $this;
443+
return $this->camel()->title();
446444
}
447445

448446
abstract public function splice(string $replacement, int $start = 0, ?int $length = null): static;

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,16 +1119,7 @@ public static function provideKebab(): array
11191119
}
11201120

11211121
/**
1122-
* @testWith ["", ""]
1123-
* ["XY", "x_y"]
1124-
* ["XuYo", "xu_yo"]
1125-
* ["SymfonyIsGreat", "symfony_is_great"]
1126-
* ["Symfony5IsGreat", "symfony_5_is_great"]
1127-
* ["SymfonyIsGreat", "Symfony is great"]
1128-
* ["SYMFONYISGREAT", "SYMFONY_IS_GREAT"]
1129-
* ["SymfonyIsAGreatFramework", "Symfony is a great framework"]
1130-
* ["SymfonyIsGREAT", "*Symfony* is GREAT!!"]
1131-
* ["SYMFONY", "SYMFONY"]
1122+
* @dataProvider providePascal
11321123
*/
11331124
public function testPascal(string $expectedString, string $origin)
11341125
{
@@ -1138,6 +1129,22 @@ public function testPascal(string $expectedString, string $origin)
11381129
$this->assertNotSame($origin, $instance, 'Strings should be immutable');
11391130
}
11401131

1132+
public static function providePascal(): array
1133+
{
1134+
return [
1135+
['', ''],
1136+
['XY', 'x_y'],
1137+
['XuYo', 'xu_yo'],
1138+
['SymfonyIsGreat', 'symfony_is_great'],
1139+
['Symfony5IsGreat', 'symfony_5_is_great'],
1140+
['SymfonyIsGreat', 'Symfony is great'],
1141+
['SYMFONYISGREAT', 'SYMFONY_IS_GREAT'],
1142+
['SymfonyIsAGreatFramework', 'Symfony is a great framework'],
1143+
['SymfonyIsGREAT', '*Symfony* is GREAT!!'],
1144+
['SYMFONY', 'SYMFONY'],
1145+
];
1146+
}
1147+
11411148
/**
11421149
* @dataProvider provideStartsWith
11431150
*/

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,24 @@ public static function provideCamel()
655655
);
656656
}
657657

658+
public static function providePascal(): array
659+
{
660+
return array_merge(
661+
parent::providePascal(),
662+
[
663+
['SymfonyIstÄußerstCool', 'symfonyIstÄußerstCool'],
664+
['SymfonyWithEmojis', 'Symfony with 😃 emojis'],
665+
]
666+
);
667+
}
668+
658669
public static function provideSnake()
659670
{
660671
return array_merge(
661672
parent::provideSnake(),
662673
[
663-
['symfony_ist_äußerst_cool', 'symfonyIstÄußerstCool'],
674+
['symfony-ist-äußerst-cool', 'symfonyIstÄußerstCool'],
675+
['symfony-with-emojis', 'Symfony with 😃 emojis'],
664676
]
665677
);
666678
}

0 commit comments

Comments
 (0)