Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
sjokkateer:arr-forget/array-access
Apr 26, 2022
Merged

taylorotwell merged 1 commit into
laravel:9.xfrom
sjokkateer:arr-forget/array-access

Conversation

@sjokkateer

Copy link
Copy Markdown
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.

2 participants