From 7af14f9be937e21837c845c1791727d043e0c9e2 Mon Sep 17 00:00:00 2001 From: Ahmet Bora Date: Tue, 10 Dec 2024 14:18:58 +0300 Subject: [PATCH] Fix ucfirst behavior #6834 --- src/Toolkit/Str.php | 2 +- tests/Toolkit/StrTest.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Toolkit/Str.php b/src/Toolkit/Str.php index 54573e088b..c4935b9115 100644 --- a/src/Toolkit/Str.php +++ b/src/Toolkit/Str.php @@ -1405,7 +1405,7 @@ public static function ucfirst(string|null $string): string { $first = static::substr($string, 0, 1); $rest = static::substr($string, 1); - return static::upper($first) . static::lower($rest); + return static::upper($first) . $rest; } /** diff --git a/tests/Toolkit/StrTest.php b/tests/Toolkit/StrTest.php index c54be52884..887db98b48 100644 --- a/tests/Toolkit/StrTest.php +++ b/tests/Toolkit/StrTest.php @@ -1492,7 +1492,10 @@ public function testTrim() public function testUcfirst() { $this->assertSame('Hello world', Str::ucfirst('hello world')); - $this->assertSame('Hello world', Str::ucfirst('Hello World')); + $this->assertSame('Hello world', Str::ucfirst('Hello world')); + $this->assertSame('Hello World', Str::ucfirst('Hello World')); + $this->assertSame('HELLO WORLD', Str::ucfirst('HELLO WORLD')); + $this->assertSame('Hello WORLD', Str::ucfirst('hello WORLD')); } /**