Skip to content

Commit

Permalink
Remove useless reduceWithKeys method (#40566)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSilber committed Jan 24, 2022
1 parent 02365bb commit 9b4f011
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 59 deletions.
15 changes: 0 additions & 15 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Expand Up @@ -785,21 +785,6 @@ class_basename(static::class), gettype($result)
return $result;
}

/**
* Reduce an associative collection to a single value.
*
* @template TReduceWithKeysInitial
* @template TReduceWithKeysReturnType
*
* @param callable(TReduceWithKeysInitial|TReduceWithKeysReturnType, TValue): TReduceWithKeysReturnType $callback
* @param TReduceWithKeysInitial $initial
* @return TReduceWithKeysReturnType
*/
public function reduceWithKeys(callable $callback, $initial = null)
{
return $this->reduce($callback, $initial);
}

/**
* Create a collection of all elements that do not pass a given truth test.
*
Expand Down
14 changes: 0 additions & 14 deletions tests/Support/SupportCollectionTest.php
Expand Up @@ -3963,20 +3963,6 @@ public function testReduce($collection)
}));
}

/**
* @dataProvider collectionClassProvider
*/
public function testReduceWithKeys($collection)
{
$data = new $collection([
'foo' => 'bar',
'baz' => 'qux',
]);
$this->assertSame('foobarbazqux', $data->reduceWithKeys(function ($carry, $element, $key) {
return $carry .= $key.$element;
}));
}

/**
* @dataProvider collectionClassProvider
*/
Expand Down
15 changes: 0 additions & 15 deletions types/Support/Collection.php
Expand Up @@ -547,21 +547,6 @@
return 1;
}, 0));

assertType('int', $collection
->reduceWithKeys(function ($null, $user) {
assertType('User', $user);
assertType('int|null', $null);

return 1;
}));
assertType('int', $collection
->reduceWithKeys(function ($int, $user) {
assertType('User', $user);
assertType('int', $int);

return 1;
}, 0));

assertType('Illuminate\Support\Collection<int, int>', $collection::make([1])->replace([1]));
assertType('Illuminate\Support\Collection<int, User>', $collection->replace([new User]));

Expand Down
15 changes: 0 additions & 15 deletions types/Support/LazyCollection.php
Expand Up @@ -546,21 +546,6 @@
return 1;
}, 0));

assertType('int', $collection
->reduceWithKeys(function ($null, $user) {
assertType('User', $user);
assertType('int|null', $null);

return 1;
}));
assertType('int', $collection
->reduceWithKeys(function ($int, $user) {
assertType('User', $user);
assertType('int', $int);

return 1;
}, 0));

assertType('Illuminate\Support\LazyCollection<int, int>', $collection::make([1])->replace([1]));
assertType('Illuminate\Support\LazyCollection<int, User>', $collection->replace([new User]));

Expand Down

0 comments on commit 9b4f011

Please sign in to comment.