Skip to content

Commit 4ff3039

Browse files
authored
Revert "[8.x] Add reduce with keys to collections and lazy collections (#35839)"
This reverts commit 08dbb8b.
1 parent 2cd4fd8 commit 4ff3039

File tree

3 files changed

+0
-50
lines changed

3 files changed

+0
-50
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -884,24 +884,6 @@ public function reduce(callable $callback, $initial = null)
884884
return array_reduce($this->items, $callback, $initial);
885885
}
886886

887-
/**
888-
* Reduce an associative collection to a single value.
889-
*
890-
* @param callable $callback
891-
* @param mixed $initial
892-
* @return mixed
893-
*/
894-
public function reduceWithKeys(callable $callback, $initial = null)
895-
{
896-
$result = $initial;
897-
898-
foreach ($this->items as $key => $value) {
899-
$result = $callback($result, $value, $key);
900-
}
901-
902-
return $result;
903-
}
904-
905887
/**
906888
* Replace the collection items with the given items.
907889
*

src/Illuminate/Collections/LazyCollection.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -845,24 +845,6 @@ public function reduce(callable $callback, $initial = null)
845845
return $result;
846846
}
847847

848-
/**
849-
* Reduce an associative collection to a single value.
850-
*
851-
* @param callable $callback
852-
* @param mixed $initial
853-
* @return mixed
854-
*/
855-
public function reduceWithKeys(callable $callback, $initial = null)
856-
{
857-
$result = $initial;
858-
859-
foreach ($this as $key => $value) {
860-
$result = $callback($result, $value, $key);
861-
}
862-
863-
return $result;
864-
}
865-
866848
/**
867849
* Replace the collection items with the given items.
868850
*

tests/Support/SupportCollectionTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,20 +3592,6 @@ public function testReduce($collection)
35923592
}));
35933593
}
35943594

3595-
/**
3596-
* @dataProvider collectionClassProvider
3597-
*/
3598-
public function testReduceWithKeys($collection)
3599-
{
3600-
$data = new $collection([
3601-
'foo' => 'bar',
3602-
'baz' => 'qux',
3603-
]);
3604-
$this->assertEquals('foobarbazqux', $data->reduceWithKeys(function ($carry, $element, $key) {
3605-
return $carry .= $key.$element;
3606-
}));
3607-
}
3608-
36093595
/**
36103596
* @dataProvider collectionClassProvider
36113597
*/

0 commit comments

Comments
 (0)