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

use func_get_args to pass array_prepend call through to Arr::prepend … #21

Merged
merged 1 commit into from
Feb 15, 2021
Merged

Conversation

trnxpace
Copy link

Currently calling array_prepend() with a missing third ($key) argument calls Arr::prepend() with three arguments, the third being the default null value from the array_prepend() definition. However, Arr::prepend() uses func_num_args() to check if the third argument is set. This leads to the element being prepended with an empty key (and any subsequent calls of array_prepend() (without supplying a third argument) overwriting the inserted element).

Using ...func_get_args() leads to the third argument of the Arr::prepend() call not being set if no third argument is supplied to array_prepend(), thus enabling correct handling of numeric indices.

…to ensure correct handling of $key argument
@taylorotwell taylorotwell merged commit ad2603f into laravel:master Feb 15, 2021
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