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

[8.x] Collection prevent null being added to resulting collection with pop and shift #38265

Prev Previous commit
Next Next commit
shift only return collection items
  • Loading branch information
craig-sen committed Aug 7, 2021
commit a60645f6521e7076fddfb000792d10959b0ade30
2 changes: 2 additions & 0 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ public function shift($count = 1)

$results = [];

$count = $count > $this->count() ? $this->count() : $count;

foreach (range(1, $count) as $item) {
array_push($results, array_shift($this->items));
}
Expand Down