[12.x] Fix inconsistent accessor attribute name conversion#11
Open
JoshSalway wants to merge 2 commits into12.xfrom
Open
[12.x] Fix inconsistent accessor attribute name conversion#11JoshSalway wants to merge 2 commits into12.xfrom
JoshSalway wants to merge 2 commits into12.xfrom
Conversation
…ution
When using the Attribute syntax (e.g. foo1Bar(): Attribute), multiple
snake_case forms like "foo_1_bar" and "foo1_bar" both map to the same
camelCase method "foo1Bar". However, only "foo1_bar" was stored in the
mutator cache (from Str::snake('foo1Bar')).
This caused append('foo_1_bar')->toArray() to fail with "Call to
undefined method getFoo1BarAttribute()" because the cache lookup for
"foo_1_bar" missed, and it fell through to the legacy accessor path.
The fix normalizes cache keys by round-tripping through camel->snake
conversion, ensuring that alternate snake_case forms resolve to the
same cache entry.
Fixes laravel#54570
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gments Verifies that both "foo1_bar" and "foo_1_bar" forms correctly resolve to the same Attribute accessor when used with append() and toArray(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
foo_1_barvsfoo1_bar)foo1Bar()method when getting values, butappend('foo_1_bar')->toArray()would fail because the mutator cache only stored the canonical formfoo1_barTest plan
foo1_barandfoo_1_barwork withappend()andtoArray()Fixes laravel#54570
🤖 Generated with Claude Code