Skip to content

Commit bf98012

Browse files
committed
Merge branch '8.x'
# Conflicts: # CHANGELOG-8.x.md # composer.json # src/Illuminate/Database/Query/Builder.php # src/Illuminate/Events/Dispatcher.php # src/Illuminate/Foundation/Application.php # src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php # src/Illuminate/Mail/composer.json # src/Illuminate/Queue/composer.json # tests/Filesystem/FilesystemAdapterTest.php
2 parents a9a225f + d470b6b commit bf98012

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

Collection.php

+34-6
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,24 @@ public function only($keys)
786786
}
787787

788788
/**
789-
* Get and remove the last item from the collection.
789+
* Get and remove the last N items from the collection.
790790
*
791+
* @param int $count
791792
* @return mixed
792793
*/
793-
public function pop()
794+
public function pop($count = 1)
794795
{
795-
return array_pop($this->items);
796+
if ($count === 1) {
797+
return array_pop($this->items);
798+
}
799+
800+
$results = [];
801+
802+
foreach (range(1, $count) as $item) {
803+
array_push($results, array_pop($this->items));
804+
}
805+
806+
return new static($results);
796807
}
797808

798809
/**
@@ -939,13 +950,24 @@ public function search($value, $strict = false)
939950
}
940951

941952
/**
942-
* Get and remove the first item from the collection.
953+
* Get and remove the first N items from the collection.
943954
*
955+
* @param int $count
944956
* @return mixed
945957
*/
946-
public function shift()
958+
public function shift($count = 1)
947959
{
948-
return array_shift($this->items);
960+
if ($count === 1) {
961+
return array_shift($this->items);
962+
}
963+
964+
$results = [];
965+
966+
foreach (range(1, $count) as $item) {
967+
array_push($results, array_shift($this->items));
968+
}
969+
970+
return new static($results);
949971
}
950972

951973
/**
@@ -1401,6 +1423,7 @@ public function pad($size, $value)
14011423
*
14021424
* @return \ArrayIterator
14031425
*/
1426+
#[\ReturnTypeWillChange]
14041427
public function getIterator()
14051428
{
14061429
return new ArrayIterator($this->items);
@@ -1411,6 +1434,7 @@ public function getIterator()
14111434
*
14121435
* @return int
14131436
*/
1437+
#[\ReturnTypeWillChange]
14141438
public function count()
14151439
{
14161440
return count($this->items);
@@ -1456,6 +1480,7 @@ public function toBase()
14561480
* @param mixed $key
14571481
* @return bool
14581482
*/
1483+
#[\ReturnTypeWillChange]
14591484
public function offsetExists($key)
14601485
{
14611486
return isset($this->items[$key]);
@@ -1467,6 +1492,7 @@ public function offsetExists($key)
14671492
* @param mixed $key
14681493
* @return mixed
14691494
*/
1495+
#[\ReturnTypeWillChange]
14701496
public function offsetGet($key)
14711497
{
14721498
return $this->items[$key];
@@ -1479,6 +1505,7 @@ public function offsetGet($key)
14791505
* @param mixed $value
14801506
* @return void
14811507
*/
1508+
#[\ReturnTypeWillChange]
14821509
public function offsetSet($key, $value)
14831510
{
14841511
if (is_null($key)) {
@@ -1494,6 +1521,7 @@ public function offsetSet($key, $value)
14941521
* @param string $key
14951522
* @return void
14961523
*/
1524+
#[\ReturnTypeWillChange]
14971525
public function offsetUnset($key)
14981526
{
14991527
unset($this->items[$key]);

LazyCollection.php

+2
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ public function pad($size, $value)
14011401
*
14021402
* @return \Traversable
14031403
*/
1404+
#[\ReturnTypeWillChange]
14041405
public function getIterator()
14051406
{
14061407
return $this->makeIterator($this->source);
@@ -1411,6 +1412,7 @@ public function getIterator()
14111412
*
14121413
* @return int
14131414
*/
1415+
#[\ReturnTypeWillChange]
14141416
public function count()
14151417
{
14161418
if (is_array($this->source)) {

Traits/EnumeratesValues.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Illuminate\Support\Enumerable;
1313
use Illuminate\Support\HigherOrderCollectionProxy;
1414
use JsonSerializable;
15-
use ReturnTypeWillChange;
1615
use Symfony\Component\VarDumper\VarDumper;
1716
use Traversable;
1817

@@ -803,7 +802,7 @@ public function toArray()
803802
*
804803
* @return array
805804
*/
806-
#[ReturnTypeWillChange]
805+
#[\ReturnTypeWillChange]
807806
public function jsonSerialize()
808807
{
809808
return array_map(function ($value) {

0 commit comments

Comments
 (0)