Skip to content

Commit

Permalink
Revert "[9.x] Adds collection key first/last. (#41450)" (#41458)
Browse files Browse the repository at this point in the history
This reverts commit 3924fba.
  • Loading branch information
taylorotwell committed Mar 12, 2022
1 parent 3924fba commit b4cbd6e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
20 changes: 0 additions & 20 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,6 @@ public function first(callable $callback = null, $default = null)
return Arr::first($this->items, $callback, $default);
}

/**
* Get the first key of the collection.
*
* @return mixed
*/
public function firstKey()
{
return array_key_first($this->items);
}

/**
* Get a flattened array of the items in the collection.
*
Expand Down Expand Up @@ -704,16 +694,6 @@ public function last(callable $callback = null, $default = null)
return Arr::last($this->items, $callback, $default);
}

/**
* Get the last key of the collection.
*
* @return mixed
*/
public function lastKey()
{
return array_key_last($this->items);
}

/**
* Get the values of a given key.
*
Expand Down
22 changes: 0 additions & 22 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ public function testFirstWithDefaultAndWithoutCallback($collection)
$this->assertSame('default', $result);
}

public function testFirstKey()
{
$data = new Collection(['foo' => 'bar', 'baz' => 'quz', 'qux' => 'quux']);

$this->assertSame('foo', $data->firstKey());

$data = new Collection(['foo', 'bar', 'baz', 'quz']);

$this->assertSame(0, $data->firstKey());
}

/**
* @dataProvider collectionClassProvider
*/
Expand Down Expand Up @@ -341,17 +330,6 @@ public function testLastWithDefaultAndWithoutCallback($collection)
$this->assertSame('default', $result);
}

public function testLastKey()
{
$data = new Collection(['foo' => 'bar', 'baz' => 'quz', 'qux' => 'quux']);

$this->assertSame('qux', $data->lastKey());

$data = new Collection(['foo', 'bar', 'baz', 'quz']);

$this->assertSame(3, $data->lastKey());
}

public function testPopReturnsAndRemovesLastItemInCollection()
{
$c = new Collection(['foo', 'bar']);
Expand Down

0 comments on commit b4cbd6e

Please sign in to comment.