From f755ac102af2205abcf8e0a4632a663378a576b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 17:57:55 +0100 Subject: [PATCH 01/13] use `ReplacesAttributes::replaceKeepCase()` also for imploded parameters --- .../Concerns/ReplacesAttributes.php | 84 +++++++------------ 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index abd5ba154a5c..d55210930e7b 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -241,14 +241,10 @@ protected function replaceMissingUnless($message, $attribute, $rule, $parameters */ protected function replaceMissingWith($message, $attribute, $rule, $parameters) { - return str_replace( - [':values', ':VALUES', ':Values'], - [ - implode(' / ', $this->getAttributeList($parameters)), - Str::upper(implode(' / ', $this->getAttributeList($parameters))), - implode(' / ', array_map(Str::ucfirst(...), $this->getAttributeList($parameters))), - ], - $message + return $this->replaceKeepCase( + $message, + ['values' => $this->getAttributeList($parameters)], + ['values' => ' / '], ); } @@ -295,14 +291,10 @@ protected function replaceIn($message, $attribute, $rule, $parameters) $parameter = $this->getDisplayableValue($attribute, $parameter); } - return str_replace( - [':values', ':VALUES', ':Values'], - [ - implode(', ', $parameters), - Str::upper(implode(', ', $parameters)), - implode(', ', array_map(Str::ucfirst(...), $parameters)), - ], + return $this->replaceKeepCase( $message, + ['values' => $this->getAttributeList($parameters)], + ['values' => ', '], ); } @@ -431,14 +423,10 @@ protected function replacePresentUnless($message, $attribute, $rule, $parameters */ protected function replacePresentWith($message, $attribute, $rule, $parameters) { - return str_replace( - [':values', ':VALUES', ':Values'], - [ - implode(' / ', $this->getAttributeList($parameters)), - Str::upper(implode(' / ', $this->getAttributeList($parameters))), - implode(' / ', array_map(Str::ucfirst(...), $this->getAttributeList($parameters))), - ], + return $this->replaceKeepCase( $message, + ['values' => $this->getAttributeList($parameters)], + ['values' => ' / '], ); } @@ -467,14 +455,10 @@ protected function replacePresentWithAll($message, $attribute, $rule, $parameter */ protected function replaceRequiredWith($message, $attribute, $rule, $parameters) { - return str_replace( - [':values', ':VALUES', ':Values'], - [ - implode(' / ', $this->getAttributeList($parameters)), - Str::upper(implode(' / ', $this->getAttributeList($parameters))), - implode(' / ', array_map(Str::ucfirst(...), $this->getAttributeList($parameters))), - ], + return $this->replaceKeepCase( $message, + ['values' => $this->getAttributeList($parameters)], + ['values' => ' / '], ); } @@ -657,17 +641,10 @@ protected function replaceRequiredUnless($message, $attribute, $rule, $parameter $values[] = $this->getDisplayableValue($parameters[0], $value); } - return str_replace( - [':other', ':OTHER', ':Other', ':values', ':VALUES', ':Values'], - [ - $other, - Str::upper($other), - Str::ucfirst($other), - implode(', ', $values), - Str::upper(implode(', ', $values)), - implode(', ', array_map(Str::ucfirst(...), $values)), - ], - $message + return $this->replaceKeepCase( + $message, + ['other' => $other, 'values' => $values], + ['values' => ', '], ); } @@ -738,14 +715,10 @@ protected function replaceProhibitedUnless($message, $attribute, $rule, $paramet */ protected function replaceProhibits($message, $attribute, $rule, $parameters) { - return str_replace( - [':other', ':OTHER', ':Other'], - [ - implode(' / ', $this->getAttributeList($parameters)), - Str::upper(implode(' / ', $this->getAttributeList($parameters))), - implode(' / ', array_map(Str::ucfirst(...), $this->getAttributeList($parameters))), - ], - $message + return $this->replaceKeepCase( + $message, + ['other' => $this->getAttributeList($parameters)], + ['other' => ' / '], ); } @@ -938,17 +911,24 @@ protected function replaceDoesntContain($message, $attribute, $rule, $parameters */ private function replaceWhileKeepingCase(string $message, array $mapping): string { - $fn = [Str::lower(...), Str::upper(...), Str::ucfirst(...)]; + $fn = [ + Str::lower(...), + Str::upper(...), + //fn (string $placeholder, ?string $parameter = null) => ucwords($parameter ?? $placeholder, $parameter !== null ? ($wordSeparators[$placeholder] ?? ' ') : ' '), + fn (string $placeholder, ?string $parameter = null) => $parameter !== null && array_key_exists($placeholder, $wordSeparators) + ? ucwords($parameter ?? $placeholder, $wordSeparators[$placeholder]) + : ucfirst($parameter ?? $placeholder), + ]; $cases = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':'.$fn($placeholder), $fn)], + fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':' . $fn($placeholder), $fn)], [], ); $replacements = array_reduce( - array_values($mapping), - fn (array $carry, string $parameter) => [...$carry, ...array_map(fn (callable $fn) => $fn($parameter), $fn)], + array_keys($mapping), + fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => $fn($placeholder, $mapping[$placeholder]), $fn)], [], ); From a44d1ddd27e5cdd3799facf2a1604b0d7323da2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:02:36 +0100 Subject: [PATCH 02/13] StyleCI --- .../Validation/Concerns/ReplacesAttributes.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index d55210930e7b..4e14ea2f1d7f 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -912,17 +912,17 @@ protected function replaceDoesntContain($message, $attribute, $rule, $parameters private function replaceWhileKeepingCase(string $message, array $mapping): string { $fn = [ - Str::lower(...), - Str::upper(...), - //fn (string $placeholder, ?string $parameter = null) => ucwords($parameter ?? $placeholder, $parameter !== null ? ($wordSeparators[$placeholder] ?? ' ') : ' '), - fn (string $placeholder, ?string $parameter = null) => $parameter !== null && array_key_exists($placeholder, $wordSeparators) - ? ucwords($parameter ?? $placeholder, $wordSeparators[$placeholder]) - : ucfirst($parameter ?? $placeholder), + Str::lower(...), + Str::upper(...), + //fn (string $placeholder, ?string $parameter = null) => ucwords($parameter ?? $placeholder, $parameter !== null ? ($wordSeparators[$placeholder] ?? ' ') : ' '), + fn (string $placeholder, ?string $parameter = null) => $parameter !== null && array_key_exists($placeholder, $wordSeparators) + ? ucwords($parameter ?? $placeholder, $wordSeparators[$placeholder]) + : ucfirst($parameter ?? $placeholder), ]; $cases = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':' . $fn($placeholder), $fn)], + fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':'.$fn($placeholder), $fn)], [], ); From 307208518774996025675b02860f895cb4289c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:08:40 +0100 Subject: [PATCH 03/13] Fix static analysis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit – Add missing method arguments – Remove duplicated condition --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index 4e14ea2f1d7f..1ff3f1bf02a1 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -908,15 +908,16 @@ protected function replaceDoesntContain($message, $attribute, $rule, $parameters * Replace the given string while maintaining different casing variants. * * @param array $mapping + * @param array $wordSeparators */ - private function replaceWhileKeepingCase(string $message, array $mapping): string + private function replaceWhileKeepingCase(string $message, array $mapping, $wordSeparators = []): string { $fn = [ Str::lower(...), Str::upper(...), //fn (string $placeholder, ?string $parameter = null) => ucwords($parameter ?? $placeholder, $parameter !== null ? ($wordSeparators[$placeholder] ?? ' ') : ' '), fn (string $placeholder, ?string $parameter = null) => $parameter !== null && array_key_exists($placeholder, $wordSeparators) - ? ucwords($parameter ?? $placeholder, $wordSeparators[$placeholder]) + ? ucwords($parameter, $wordSeparators[$placeholder]) : ucfirst($parameter ?? $placeholder), ]; From 886713bde188f54a902d57fd6d6b9cbc590d62ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:17:12 +0100 Subject: [PATCH 04/13] Update method name in call to align with the changes made in 78861ff9756e2bf31fbe4efed08293a2f237e040 --- .../Validation/Concerns/ReplacesAttributes.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index 1ff3f1bf02a1..cffa38762c0b 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -241,7 +241,7 @@ protected function replaceMissingUnless($message, $attribute, $rule, $parameters */ protected function replaceMissingWith($message, $attribute, $rule, $parameters) { - return $this->replaceKeepCase( + return $this->replaceWhileKeepingCase( $message, ['values' => $this->getAttributeList($parameters)], ['values' => ' / '], @@ -291,7 +291,7 @@ protected function replaceIn($message, $attribute, $rule, $parameters) $parameter = $this->getDisplayableValue($attribute, $parameter); } - return $this->replaceKeepCase( + return $this->replaceWhileKeepingCase( $message, ['values' => $this->getAttributeList($parameters)], ['values' => ', '], @@ -423,7 +423,7 @@ protected function replacePresentUnless($message, $attribute, $rule, $parameters */ protected function replacePresentWith($message, $attribute, $rule, $parameters) { - return $this->replaceKeepCase( + return $this->replaceWhileKeepingCase( $message, ['values' => $this->getAttributeList($parameters)], ['values' => ' / '], @@ -455,7 +455,7 @@ protected function replacePresentWithAll($message, $attribute, $rule, $parameter */ protected function replaceRequiredWith($message, $attribute, $rule, $parameters) { - return $this->replaceKeepCase( + return $this->replaceWhileKeepingCase( $message, ['values' => $this->getAttributeList($parameters)], ['values' => ' / '], @@ -641,7 +641,7 @@ protected function replaceRequiredUnless($message, $attribute, $rule, $parameter $values[] = $this->getDisplayableValue($parameters[0], $value); } - return $this->replaceKeepCase( + return $this->replaceWhileKeepingCase( $message, ['other' => $other, 'values' => $values], ['values' => ', '], @@ -715,7 +715,7 @@ protected function replaceProhibitedUnless($message, $attribute, $rule, $paramet */ protected function replaceProhibits($message, $attribute, $rule, $parameters) { - return $this->replaceKeepCase( + return $this->replaceWhileKeepingCase( $message, ['other' => $this->getAttributeList($parameters)], ['other' => ' / '], From eb8f9f733c604b7a5c4161a9588809bbf9f9943f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:30:39 +0100 Subject: [PATCH 05/13] Fix argument order in method call --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index cffa38762c0b..d511566d8a77 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -929,7 +929,7 @@ private function replaceWhileKeepingCase(string $message, array $mapping, $wordS $replacements = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => $fn($placeholder, $mapping[$placeholder]), $fn)], + fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => $fn($mapping[$placeholder], $placeholder), $fn)], [], ); From 768dac77a8cb80c6c9df53064b43b8cc7bdbe020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:55:20 +0100 Subject: [PATCH 06/13] Separate ucwords() logic for cases and replacements --- .../Validation/Concerns/ReplacesAttributes.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index d511566d8a77..f7aebf0092ff 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -916,20 +916,21 @@ private function replaceWhileKeepingCase(string $message, array $mapping, $wordS Str::lower(...), Str::upper(...), //fn (string $placeholder, ?string $parameter = null) => ucwords($parameter ?? $placeholder, $parameter !== null ? ($wordSeparators[$placeholder] ?? ' ') : ' '), - fn (string $placeholder, ?string $parameter = null) => $parameter !== null && array_key_exists($placeholder, $wordSeparators) - ? ucwords($parameter, $wordSeparators[$placeholder]) - : ucfirst($parameter ?? $placeholder), ]; + + $ucwordsReplacement = fn (string $parameter, string $placeholder) => array_key_exists($placeholder, $wordSeparators) + ? ucwords($placeholder, $wordSeparators[$placeholder]) + : ucfirst($parameter); $cases = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':'.$fn($placeholder), $fn)], + fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':'.$fn($placeholder), [...$fn, ucfirst(...)])], [], ); $replacements = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => $fn($mapping[$placeholder], $placeholder), $fn)], + fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => $fn($mapping[$placeholder], $placeholder), [...$fn, $ucwordsReplacement])], [], ); From 24785e7754f279e8ae175e4c3264c735f488e6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:56:14 +0100 Subject: [PATCH 07/13] StyleCI --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index f7aebf0092ff..f7f76e2cfc05 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -917,7 +917,7 @@ private function replaceWhileKeepingCase(string $message, array $mapping, $wordS Str::upper(...), //fn (string $placeholder, ?string $parameter = null) => ucwords($parameter ?? $placeholder, $parameter !== null ? ($wordSeparators[$placeholder] ?? ' ') : ' '), ]; - + $ucwordsReplacement = fn (string $parameter, string $placeholder) => array_key_exists($placeholder, $wordSeparators) ? ucwords($placeholder, $wordSeparators[$placeholder]) : ucfirst($parameter); From e594617636ef9c75803593e0b48606c19e2212f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 19:04:15 +0100 Subject: [PATCH 08/13] Fix --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index f7f76e2cfc05..694625d7e138 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -293,7 +293,7 @@ protected function replaceIn($message, $attribute, $rule, $parameters) return $this->replaceWhileKeepingCase( $message, - ['values' => $this->getAttributeList($parameters)], + ['values' => $parameters], ['values' => ', '], ); } From 5c75f2dc113e1be8177620ff99eb146b35165d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 19:04:28 +0100 Subject: [PATCH 09/13] Type --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index 694625d7e138..d212b825c9c7 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -910,7 +910,7 @@ protected function replaceDoesntContain($message, $attribute, $rule, $parameters * @param array $mapping * @param array $wordSeparators */ - private function replaceWhileKeepingCase(string $message, array $mapping, $wordSeparators = []): string + private function replaceWhileKeepingCase(string $message, array $mapping, array $wordSeparators = []): string { $fn = [ Str::lower(...), From 4b1d736cadf8d55d87cc8ae363aa3c9e45b16189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 19:12:34 +0100 Subject: [PATCH 10/13] Allow array replacements by using already passed $wordSeparators --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index d212b825c9c7..e26c318a8dcd 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -930,7 +930,13 @@ private function replaceWhileKeepingCase(string $message, array $mapping, array $replacements = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => $fn($mapping[$placeholder], $placeholder), [...$fn, $ucwordsReplacement])], + fn (array $carry, string $placeholder) => [...$carry, ...array_map(function (callable $fn) use($placeholder, $mapping, $wordSeparators) { + $parameter = $mapping[$placeholder]; + if (is_array($parameter) && array_is_list($parameter) && array_key_exists($placeholder, $wordSeparators)) { + $parameter = implode($wordSeparators[$placeholder], $parameter); + } + return $fn($parameter, $placeholder); + }, [...$fn, $ucwordsReplacement])], [], ); From e9fcf5eace97a82560a9e1f568fa69ed107ee0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 19:13:37 +0100 Subject: [PATCH 11/13] StyleCI --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index e26c318a8dcd..378f25d93f95 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -930,11 +930,12 @@ private function replaceWhileKeepingCase(string $message, array $mapping, array $replacements = array_reduce( array_keys($mapping), - fn (array $carry, string $placeholder) => [...$carry, ...array_map(function (callable $fn) use($placeholder, $mapping, $wordSeparators) { + fn (array $carry, string $placeholder) => [...$carry, ...array_map(function (callable $fn) use ($placeholder, $mapping, $wordSeparators) { $parameter = $mapping[$placeholder]; if (is_array($parameter) && array_is_list($parameter) && array_key_exists($placeholder, $wordSeparators)) { $parameter = implode($wordSeparators[$placeholder], $parameter); } + return $fn($parameter, $placeholder); }, [...$fn, $ucwordsReplacement])], [], From 94bdfa289565c565bfaf7233724c349368dbf363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:20:28 +0100 Subject: [PATCH 12/13] Fix casing See https://github.com/laravel/framework/pull/57564#issuecomment-3457631210 --- tests/Validation/ValidationValidatorTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index b6ec5ac6722f..3289c50784a9 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -816,12 +816,12 @@ public function testDisplayableValuesAreReplaced() // in:foo,bar,... $trans = $this->getIlluminateArrayTranslator(); $trans->addLines(['validation.in' => ':attribute must be included in :values.'], 'en'); - $trans->addLines(['validation.values.type.5' => 'Short'], 'en'); - $trans->addLines(['validation.values.type.300' => 'Long'], 'en'); + $trans->addLines(['validation.values.type.5' => 'short'], 'en'); + $trans->addLines(['validation.values.type.300' => 'long'], 'en'); $v = new Validator($trans, ['type' => '4'], ['type' => 'in:5,300']); $this->assertFalse($v->passes()); $v->messages()->setFormat(':message'); - $this->assertSame('type must be included in Short, Long.', $v->messages()->first('type')); + $this->assertSame('type must be included in short, long.', $v->messages()->first('type')); // date_equals:tomorrow $trans = $this->getIlluminateArrayTranslator(); @@ -837,30 +837,30 @@ public function testDisplayableValuesAreReplaced() $trans->addLines(['validation.in' => ':attribute must be included in :values.'], 'en'); $customValues = [ 'type' => [ - '5' => 'Short', - '300' => 'Long', + '5' => 'short', + '300' => 'long', ], ]; $v = new Validator($trans, ['type' => '4'], ['type' => 'in:5,300']); $v->addCustomValues($customValues); $this->assertFalse($v->passes()); $v->messages()->setFormat(':message'); - $this->assertSame('type must be included in Short, Long.', $v->messages()->first('type')); + $this->assertSame('type must be included in short, long.', $v->messages()->first('type')); // set custom values by setter $trans = $this->getIlluminateArrayTranslator(); $trans->addLines(['validation.in' => ':attribute must be included in :values.'], 'en'); $customValues = [ 'type' => [ - '5' => 'Short', - '300' => 'Long', + '5' => 'short', + '300' => 'long', ], ]; $v = new Validator($trans, ['type' => '4'], ['type' => 'in:5,300']); $v->setValueNames($customValues); $this->assertFalse($v->passes()); $v->messages()->setFormat(':message'); - $this->assertSame('type must be included in Short, Long.', $v->messages()->first('type')); + $this->assertSame('type must be included in short, long.', $v->messages()->first('type')); } public function testDisplayableAttributesAreReplacedInCustomReplacers() From 261450b563a096eb1fa31ea1d1799b05e38a001f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:29:33 +0100 Subject: [PATCH 13/13] Fix --- src/Illuminate/Validation/Concerns/ReplacesAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php index 378f25d93f95..f070a30de609 100644 --- a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ReplacesAttributes.php @@ -919,7 +919,7 @@ private function replaceWhileKeepingCase(string $message, array $mapping, array ]; $ucwordsReplacement = fn (string $parameter, string $placeholder) => array_key_exists($placeholder, $wordSeparators) - ? ucwords($placeholder, $wordSeparators[$placeholder]) + ? ucwords($parameter, $wordSeparators[$placeholder]) : ucfirst($parameter); $cases = array_reduce(