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

Add a description of Arr::add when the key exists and its value is null #5064

Closed
wants to merge 1 commit into from

Conversation

crhg
Copy link

@crhg crhg commented Mar 15, 2019

Currently Arr::add is described as follows:

The Arr::add method adds a given key / value pair to an array if the given key does not already exist in the array:

However, the value is updated when the key exists and the value is null.

>>> Arr::add(['price' => null], 'price', 100)
=> [
     "price" => 100,
   ]

This PR adds a description of that case.

A PR has been submitted that corrects this behavior (laravel/framework #12960), and at that time it was judged as 'Since this is a behavior change will hold off on this.'.

It would be difficult to make change that breaks backwards compatibility, so I think it would be better to have a description of this behavior.

@taylorotwell
Copy link
Member

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants