Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,21 +802,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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