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.6] Let Arr::wrap(null) return empty array #21745

Merged

Conversation

@manniL
Copy link
Contributor

@manniL manniL commented Oct 19, 2017

Change Arr::wrap function to return an empty array when providing null as argument. This is the same way Ruby handles it and also more intuitive IMO

@sisve
Copy link
Contributor

@sisve sisve commented Oct 19, 2017

The semantics of the word "wrap" indicate, to me, that I will get whatever value I pass in wrapped in an array. Sure, there's a special-case for arrays, and that annoys me, but I disagree on adding more of these special cases.

Why shouldn't count(Arr::wrap($value)) === 1 for non-arrays?

@@ -601,6 +601,10 @@ public static function where($array, callable $callback)
*/

This comment has been minimized.

@jmarcher

jmarcher Oct 19, 2017
Contributor

Change comment: "If the given value is not an array, wrap it in one." is no longer true in this case.

This comment has been minimized.

@manniL

manniL Oct 19, 2017
Author Contributor

Done ☺️

@manniL
Copy link
Contributor Author

@manniL manniL commented Oct 19, 2017

@sisve I understand your thoughts. In the end, it's a design decision. But for me, it appears to be more useful like Ruby implemented it.

@taylorotwell taylorotwell merged commit b345fdf into laravel:master Oct 19, 2017
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/styleci/pr The StyleCI analysis has passed
Details
@taylorotwell
Copy link
Member

@taylorotwell taylorotwell commented Oct 19, 2017

I do like matching other ecosystems where possible.

@manniL manniL deleted the manniL:feature-array-wrap-empty-array-on-null branch Oct 19, 2017
@thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Oct 22, 2017

This also matches the array cast in PHP. (array) null === []

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

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.