From 4ff30390dec4f9728b0ee5c8729e995a0a9e4b67 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 13 Jan 2021 11:35:04 -0600 Subject: [PATCH] Revert "[8.x] Add reduce with keys to collections and lazy collections (#35839)" This reverts commit 08dbb8bea12104974ba86337bd37e0471254f39b. --- src/Illuminate/Collections/Collection.php | 18 ------------------ src/Illuminate/Collections/LazyCollection.php | 18 ------------------ tests/Support/SupportCollectionTest.php | 14 -------------- 3 files changed, 50 deletions(-) diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 6a8ab88818aa..f4c7b4007a91 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -884,24 +884,6 @@ public function reduce(callable $callback, $initial = null) return array_reduce($this->items, $callback, $initial); } - /** - * Reduce an associative collection to a single value. - * - * @param callable $callback - * @param mixed $initial - * @return mixed - */ - public function reduceWithKeys(callable $callback, $initial = null) - { - $result = $initial; - - foreach ($this->items as $key => $value) { - $result = $callback($result, $value, $key); - } - - return $result; - } - /** * Replace the collection items with the given items. * diff --git a/src/Illuminate/Collections/LazyCollection.php b/src/Illuminate/Collections/LazyCollection.php index ca51626b071e..2384948f951a 100644 --- a/src/Illuminate/Collections/LazyCollection.php +++ b/src/Illuminate/Collections/LazyCollection.php @@ -845,24 +845,6 @@ public function reduce(callable $callback, $initial = null) return $result; } - /** - * Reduce an associative collection to a single value. - * - * @param callable $callback - * @param mixed $initial - * @return mixed - */ - public function reduceWithKeys(callable $callback, $initial = null) - { - $result = $initial; - - foreach ($this as $key => $value) { - $result = $callback($result, $value, $key); - } - - return $result; - } - /** * Replace the collection items with the given items. * diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index b622884fe6c1..6faf65a1a3c2 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -3592,20 +3592,6 @@ public function testReduce($collection) })); } - /** - * @dataProvider collectionClassProvider - */ - public function testReduceWithKeys($collection) - { - $data = new $collection([ - 'foo' => 'bar', - 'baz' => 'qux', - ]); - $this->assertEquals('foobarbazqux', $data->reduceWithKeys(function ($carry, $element, $key) { - return $carry .= $key.$element; - })); - } - /** * @dataProvider collectionClassProvider */