Skip to content

Conversation

@florianraith
Copy link
Contributor

This PR reverts the minor breaking change around placeholder capitalization reported in #57678. The issue was that certain placeholder values were explicitly lowercased, whereas previously they were not. This PR restores the prior behavior and keeps things consistent again with :attribute, which does not explicitly lowercase.

Example

$trans->addLines(['validation.accepted_if' => 'The :attribute field must be accepted when :other is :value.'], 'en');
$v = new Validator($trans, ['foo' => 'no', 'bar' => 'aAa'], ['foo' => 'accepted_if:bar,aAa']);
echo $v->messages()->first('foo');

// Currently (after the breaking change):
// The foo field must be accepted when bar is aaa.

// Previously (expected behavior):
// The foo field must be accepted when bar is aAa.

The change was introduced in #57564 and already pointed out by #57564 (comment).
Several attempts to fix this have already been made (#57679, #57686). This PR simply removes the Str::lower(...) call. It focuses on reverting the breaking change and introducing test cases to ensure future correctness. Others are welcome to open further PRs for refactoring if deemed necessary.

I've gone through each rule and manually checked if the lowercasing change affected them:

  • accepted_if:
    :other — no; field name is converted to snake_case, so explicit lowercasing has no additional effect
    :value — yes

  • same, in_array, prohibits:
    :other — no; field name is converted to snake_case

  • missing_with, required_with, present_with:
    :values — no; field names are converted to snake_case

  • required_unless, starts_with:
    no — does not use replaceWhileKeepingCase, which introduced the change (test cases still added for completeness)

For all the listed rules above there are unique method implementations inside ReplacesAttributes. Methods for other rules just call one of the above rules' methods (e.g., replaceRequiredIf calls replaceAcceptedIf). This is also why, in my initial PR #57556, I only added test cases for the rules above, as they cover the remaining delegated rules as well.

@shaedrich
Copy link
Contributor

Thanks for coding the revert 👍🏻

@taylorotwell taylorotwell merged commit 5b3cc40 into laravel:12.x Nov 10, 2025
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants