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
[5.6] Let Arr::wrap(null) return empty array #21745
Conversation
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 |
@@ -601,6 +601,10 @@ public static function where($array, callable $callback) | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change comment: "If the given value is not an array, wrap it in one." is no longer true in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@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. |
I do like matching other ecosystems where possible. |
This also matches the array cast in PHP. |
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