From e7a31e2f2876ded37f7b35c092ebbb7da2628ed6 Mon Sep 17 00:00:00 2001 From: Christophe Francey Date: Thu, 6 Nov 2025 09:03:13 +0100 Subject: [PATCH 1/2] add missing separators to Stringable `ucwords` --- src/Illuminate/Support/Stringable.php | 4 ++-- tests/Support/SupportStringableTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index 21fbe3fff860..44da3f9bd5b5 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -1112,9 +1112,9 @@ public function ucfirst() * * @return static */ - public function ucwords() + public function ucwords($separators = " \t\r\n\f\v") { - return new static(Str::ucwords($this->value)); + return new static(Str::ucwords($this->value, $separators)); } /** diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php index 8302193c596f..56dd427dd1da 100644 --- a/tests/Support/SupportStringableTest.php +++ b/tests/Support/SupportStringableTest.php @@ -180,6 +180,16 @@ public function testCanBeLimitedByWords() $this->assertSame('Taylor Otwell', (string) $this->stringable('Taylor Otwell')->words(3)); } + public function testUcwords() + { + $this->assertSame('Laravel', (string) $this->stringable('laravel')->ucwords()); + $this->assertSame('Laravel Framework', (string) $this->stringable('laravel framework')->ucwords()); + $this->assertSame('Laravel-Framework', (string) $this->stringable('laravel-framework')->ucwords('-')); + $this->assertSame('Мама', (string) $this->stringable('мама')->ucwords()); + $this->assertSame('Мама Мыла Раму', (string) $this->stringable('мама мыла раму')->ucwords()); + $this->assertSame('JJ Watt', (string) $this->stringable('JJ watt')->ucwords()); + } + public function testUnless() { $this->assertSame('unless false', (string) $this->stringable('unless')->unless(false, function ($stringable, $value) { From 03f0756f6b72cc8b6b26696f915bf83dea87a29c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 6 Nov 2025 08:27:06 -0600 Subject: [PATCH 2/2] Update Stringable.php --- src/Illuminate/Support/Stringable.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index 44da3f9bd5b5..67c4b9b5ddd5 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -1110,6 +1110,7 @@ public function ucfirst() /** * Capitalize the first character of each word in a string. * + * @param string $separators * @return static */ public function ucwords($separators = " \t\r\n\f\v")