Skip to content

Commit b4cbd6e

Browse files
authored
Revert "[9.x] Adds collection key first/last. (#41450)" (#41458)
This reverts commit 3924fba.
1 parent 3924fba commit b4cbd6e

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,6 @@ public function first(callable $callback = null, $default = null)
389389
return Arr::first($this->items, $callback, $default);
390390
}
391391

392-
/**
393-
* Get the first key of the collection.
394-
*
395-
* @return mixed
396-
*/
397-
public function firstKey()
398-
{
399-
return array_key_first($this->items);
400-
}
401-
402392
/**
403393
* Get a flattened array of the items in the collection.
404394
*
@@ -704,16 +694,6 @@ public function last(callable $callback = null, $default = null)
704694
return Arr::last($this->items, $callback, $default);
705695
}
706696

707-
/**
708-
* Get the last key of the collection.
709-
*
710-
* @return mixed
711-
*/
712-
public function lastKey()
713-
{
714-
return array_key_last($this->items);
715-
}
716-
717697
/**
718698
* Get the values of a given key.
719699
*

tests/Support/SupportCollectionTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,6 @@ public function testFirstWithDefaultAndWithoutCallback($collection)
6969
$this->assertSame('default', $result);
7070
}
7171

72-
public function testFirstKey()
73-
{
74-
$data = new Collection(['foo' => 'bar', 'baz' => 'quz', 'qux' => 'quux']);
75-
76-
$this->assertSame('foo', $data->firstKey());
77-
78-
$data = new Collection(['foo', 'bar', 'baz', 'quz']);
79-
80-
$this->assertSame(0, $data->firstKey());
81-
}
82-
8372
/**
8473
* @dataProvider collectionClassProvider
8574
*/
@@ -341,17 +330,6 @@ public function testLastWithDefaultAndWithoutCallback($collection)
341330
$this->assertSame('default', $result);
342331
}
343332

344-
public function testLastKey()
345-
{
346-
$data = new Collection(['foo' => 'bar', 'baz' => 'quz', 'qux' => 'quux']);
347-
348-
$this->assertSame('qux', $data->lastKey());
349-
350-
$data = new Collection(['foo', 'bar', 'baz', 'quz']);
351-
352-
$this->assertSame(3, $data->lastKey());
353-
}
354-
355333
public function testPopReturnsAndRemovesLastItemInCollection()
356334
{
357335
$c = new Collection(['foo', 'bar']);

0 commit comments

Comments
 (0)