Skip to content

Fix array access with a Stringable key on ArrayAccess objects using object keys#4856

Merged
fabpot merged 1 commit into
twigphp:3.xfrom
fabpot:fix-arrayaccess-stringable-key
Jul 8, 2026
Merged

Fix array access with a Stringable key on ArrayAccess objects using object keys#4856
fabpot merged 1 commit into
twigphp:3.xfrom
fabpot:fix-arrayaccess-stringable-key

Conversation

@fabpot

@fabpot fabpot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closes #4855

@upsun-dispatch

upsun-dispatch Bot commented Jul 7, 2026

Copy link
Copy Markdown

📋 PR Summary

This PR fixes array access in Twig's GetAttrExpression so that a Stringable object used as a key is handled correctly when accessing ArrayAccess objects. It updates the attribute-resolution logic and adds test coverage for the object-key scenario.

Changes
Layer / File(s) Summary
Array access — Stringable key handling
src/Node/Expression/GetAttrExpression.php Adjusts attribute-resolution logic so a Stringable object key is correctly resolved when indexing into ArrayAccess objects.
tests/TemplateTest.php Adds tests covering array access with a Stringable/object key on ArrayAccess objects.
Docs
CHANGELOG Adds a changelog entry describing the fix.

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Upsun Dispatch Review: full · 3 files reviewed · no issues found

Review details

Commit: Commit 679b8fd
Model: claude-opus-4-8
Panel: correctness · robustness

@fabpot fabpot merged commit 8ada671 into twigphp:3.x Jul 8, 2026
42 of 43 checks passed
@fabpot fabpot deleted the fix-arrayaccess-stringable-key branch July 8, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Since v3.27.1: ArrayAccess with Stringable object keys is not working anymore

1 participant