-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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 handle shift()
on an empty collection
#51841
[10.x] fix handle shift()
on an empty collection
#51841
Conversation
@@ -1134,7 +1134,11 @@ public function shift($count = 1) | |||
throw new InvalidArgumentException('Number of shifted items may not be less than zero.'); | |||
} | |||
|
|||
if ($count === 0 || $this->isEmpty()) { | |||
if ($this->isEmpty()) { |
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.
I think this is the correct placement for the isEmpty()
check. We want to make sure that there are items to use before we continue to handle the rest.
Also this maintains the behaviour as it was prior to the mentioned PR.
Yikes. This has broken at least one 3rd party package that depending on |
Same, our tests started failing. So hence this PR. Just waiting on the release. In the mean time we updated our codebase to use the native |
I just cut a new release that includes this one. |
fixes #51840
This PR fixes how the
Collection::shift()
method handles an empty collection.Currently it will return the collection when trying to call
shift()
on an empty collection. Before it would return null.steps to reproduce
This is also covered in the added test.