-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[10.x] Fix collection items pop when count is 0 or less than 0. #51699
Conversation
Why is |
Ah ok, from the code I see it returns an empty collection instead, that might have been an error on your examples |
Thank you, what is proposed indeed returns the whole collection when we |
I would not expect anything to be returned then, "since no items are popped" When a greater than zero value is provided, items removed from the collection are returned. Why should anything be returned if no items were removed? I would expect either to receive an empty array (in line with the recently merged PR for |
As for greater than zero values, all items returned are removed from the original collection, if all items are returned, when |
Fixing pop(0) and adding relevant tests. Co-authored-by: Faissal Wahabali <[email protected]>
Adding tests. Co-authored-by: Faissal Wahabali <[email protected]>
Thank you @rodrigopedra @faissaloux, batched. |
I don't want to mess with this method. |
Hello
Building upon the improvements from Issue #51684 and in merged PR #51686; the
pop
method in Laravel's Collection class does not correctly handle cases where the$count
parameter is zero or negative.This proposal seeks to refine the method's behavior to:
$count
is zero.$count
is less than zero.Current
Expected
I hope you find this helpful.
Thank you