8000 Remove useless reduceWithKeys method (#40566) · laravel/framework@9b4f011 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b4f011

Browse files
authored
Remove useless reduceWithKeys method (#40566)
1 parent 02365bb commit 9b4f011

File tree

4 files changed

+0
-59
lines changed

4 files changed

+0
-59
lines changed

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -785,21 +785,6 @@ class_basename(static::class), gettype($result)
785785
return $result;
786786
}
787787

788-
/**
789-
* Reduce an associative collection to a single value.
790-
*
791-
* @template TReduceWithKeysInitial
792-
* @template TReduceWithKeysReturnType
793-
*
794-
* @param callable(TReduceWithKeysInitial|TReduceWithKeysReturnType, TValue): TReduceWithKeysReturnType $callback
795-
* @param TReduceWithKeysInitial $initial
796-
* @return TReduceWithKeysReturnType
797-
*/
798-
public function reduceWithKeys(callable $callback, $initial = null)
799-
{
800-
return $this->reduce($callback, $initial);
801-
}
802-
803788
/**
804789
* Create a collection of all elements that do not pass a given truth test.
805790
*

tests/Support/SupportCollectionTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,20 +3963,6 @@ public function testReduce($collection)
39633963
}));
39643964
}
39653965

3966-
/**
3967-
* @dataProvider collectionClassProvider
3968-
*/
3969-
public function testReduceWithKeys($collection)
3970-
{
3971-
$data = new $collection([
3972-
'foo' => 'bar',
3973-
'baz' => 'qux',
3974-
]);
3975-
$this->assertSame('foobarbazqux', $data->reduceWithKeys(function ($carry, $element, $key) {
3976-
return $carry .= $key.$element;
3977-
}));
3978-
}
3979-
39803966
/**
39813967
* @dataProvider collectionClassProvider
39823968
*/

types/Support/Collection.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -547,21 +547,6 @@
547547
return 1;
548548
}, 0));
549549

550-
assertType('int', $collection
551-
->reduceWithKeys(function ($null, $user) {
552-
assertType('User', $user);
553-
assertType('int|null', $null);
554-
555-
return 1;
556-
}));
557-
assertType('int', $collection
558-
->reduceWithKeys(function ($int, $user) {
559-
assertType('User', $user);
560-
assertType('int', $int);
561-
562-
return 1;
563-
}, 0));
564-
565550
assertType('Illuminate\Support\Collection<int, int>', $collection::make([1])->replace([1]));
566551
assertType('Illuminate\Support\Collection<int, User>', $collection->replace([new User]));
567552

types/Support/LazyCollection.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -546,21 +546,6 @@
546546
return 1;
547547
}, 0));
548548

549-
assertType('int', $collection
550-
->reduceWithKeys(function ($null, $user) {
551-
assertType('User', $user);
552-
assertType('int|null', $null);
553-
554-
return 1;
555-
}));
556-
assertType('int', $collection
557-
->reduceWithKeys(function ($int, $user) {
558-
assertType('User', $user);
559-
assertType('int', $int);
560-
561-
return 1;
562-
}, 0));
563-
564549
assertType('Illuminate\Support\LazyCollection<int, int>', $collection::make([1])->replace([1]));
565550
assertType('Illuminate\Support\LazyCollection<int, User>', $collection->replace([new User]));
566551

0 commit comments

Comments
 (0)
0