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

[9.x] Arr::forget() for nested ArrayAccess objects #42142

Merged
merged 1 commit into from
Apr 26, 2022
Merged

[9.x] Arr::forget() for nested ArrayAccess objects #42142

merged 1 commit into from
Apr 26, 2022

Conversation

sjokkateer
Copy link
Contributor

Currently, calling Collection::pull() using a dot notatation key when dealing with nested ArrayAccess::class objects would result in the correct value being returned but it would not remove the key/value from the objects afterwards.
This is because the original call is forwarded to Arr::pull(), which calls Arr::forget(), and in Arr::forget() line 288 the conditional tests only for the value being an array through is_array.
Changing this part of the conditional to Arr::accessible() makes the method return not only the correct value but also remove the corresponding key when dealing with nested ArrayAccess::class objects.

If I am not mistaken this change should be fully backward compatible.

If there is anything I overlooked please let me know!

@taylorotwell taylorotwell merged commit 9035ea6 into laravel:9.x Apr 26, 2022
@GrahamCampbell GrahamCampbell changed the title [Fix] Arr::forget() for nested ArrayAccess objects [9.x] Arr::forget() for nested ArrayAccess objects Apr 26, 2022
chu121su12 pushed a commit to chu121su12/framework that referenced this pull request Apr 29, 2022
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.

None yet

2 participants