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

[5.5] Add the power of Arr::get() to Collection get() #22554

Merged
merged 4 commits into from
Dec 28, 2017
Merged

[5.5] Add the power of Arr::get() to Collection get() #22554

merged 4 commits into from
Dec 28, 2017

Conversation

nmfzone
Copy link
Contributor

@nmfzone nmfzone commented Dec 28, 2017

By using Arr::get(), now It's possible to get nested value using collection get().

By using Arr::get(), now It's possible to get nested value using collection get().
@nmfzone nmfzone changed the title [5.5] Add the power of Arr::get() to Collection [5.5] Add the power of Arr::get() to Collection get() Dec 28, 2017
@Dylan-DPC-zz
Copy link

and tests …

@nmfzone
Copy link
Contributor Author

nmfzone commented Dec 28, 2017

@Dylan-DPC Thanks..

@taylorotwell taylorotwell merged commit 225cfa8 into laravel:5.5 Dec 28, 2017
@sisve
Copy link
Contributor

sisve commented Dec 28, 2017

Are we really really sure that we can just add new wildcard capabilities to such a globally used class like Collection without causing problems for people? Are we really sure that no one use ::get($key) with keys that already looks like wildcards?

@Miguel-Serejo
Copy link

Arr::get() first checks if the full key exists in the array before trying to access sub-arrays using the dot notation. It also doesn't do wildcards.

@jeroennoten
Copy link
Contributor

jeroennoten commented Jan 16, 2018

Strictly spoken, this is a breaking change:

(new Collection(['a' => ['b' => 'c']]))->get('a.b', 'd')

returned 'd' in the old situation and 'c' in the new situation.

@sisve
Copy link
Contributor

sisve commented Jan 16, 2018

@jeroennoten Yes, but can we do anything about it? It has already been merged and released.

@jeroennoten
Copy link
Contributor

A rollback in a next version is an option. This is already done more often than once (e.g. #22478).

But not sure if that is necessary, my comment was more or less informative without opinion.

@jasonvarga
Copy link
Contributor

jasonvarga commented Jan 17, 2018

I also noticed that $collection->get(null) will now return the whole array. Before this change, it would have returned null.

@mariosvasiliou
Copy link

The new method not working as it should. I have the same problem. default value is always ignored and whole array is returned instead of null....

@devcircus
Copy link
Contributor

If you're experiencing problems that you believe is a bug, please open an issue and explain the problem in detail, including a description of the behavior before and after this pr. Your issue will be noticed much more quickly there than on a closed pr.

@sisve
Copy link
Contributor

sisve commented Jan 18, 2018

Note how there's now a commit with the message "revert breaking change", but it didn't actually revert anything.

There's now a follow up for the default value at #22837, but we're still using Arr::get which @jeroennoten has shown is a change in behavior.

@taylorotwell
Copy link
Member

Reverting this entirely.

@laravel laravel locked and limited conversation to collaborators Jan 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants