Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ArrayAccess with objects as keys #4496

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

gharlan
Copy link
Contributor

@gharlan gharlan commented Dec 5, 2024

fixes #4476
The bug was introduced in 3.15 via #4425 (comment)

@@ -1644,7 +1644,7 @@ public static function getAttribute(Environment $env, Source $source, $object, $

// array
if (Template::METHOD_CALL !== $type) {
$arrayItem = \is_bool($item) || \is_float($item) ? (int) $item : $item = (string) $item;
$arrayItem = \is_bool($item) || \is_float($item) ? (int) $item : $item;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas I'm not sure if there was a good reason for the string casting. So maybe it should be done somewhere else? Or is it ok to just remove the casting?

Copy link
Contributor

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Thanks for the regression test, that's what was missing.

@fabpot
Copy link
Contributor

fabpot commented Dec 10, 2024

Thank you @gharlan.

@fabpot fabpot merged commit d8a798c into twigphp:3.x Dec 10, 2024
48 of 50 checks passed
@gharlan gharlan deleted the fix-object-storage branch December 10, 2024 15:32
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.

In version 3.15.0, when accessing SplObjectStorage by index (object), an error is generated
3 participants