Skip to content

Commit 7854c34

Browse files
authored
Fixes Collection::groupBy types (#40373)
1 parent 9adc7a8 commit 7854c34

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public function get($key, $default = null)
447447
*
448448
* @param (callable(TValue, TKey): array-key)|array|string $groupBy
449449
* @param bool $preserveKeys
450-
* @return static<array-key, array<array-key, TValue>>
450+
* @return static<array-key, static<array-key, TValue>>
451451
*/
452452
public function groupBy($groupBy, $preserveKeys = false)
453453
{

src/Illuminate/Collections/Enumerable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public function get($key, $default = null);
505505
*
506506
* @param (callable(TValue, TKey): array-key)|array|string $groupBy
507507
* @param bool $preserveKeys
508-
* @return static<array-key, array<array-key, TValue>>
508+
* @return static<array-key, static<array-key, TValue>>
509509
*/
510510
public function groupBy($groupBy, $preserveKeys = false);
511511

src/Illuminate/Collections/LazyCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public function get($key, $default = null)
507507
*
508508
* @param (callable(TValue, TKey): array-key)|array|string $groupBy
509509
* @param bool $preserveKeys
510-
* @return static<array-key, array<array-key, TValue>>
510+
* @return static<array-key, static<array-key, TValue>>
511511
*/
512512
public function groupBy($groupBy, $preserveKeys = false)
513513
{

types/Support/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@
376376

377377
assertType('Illuminate\Support\Collection<string, int>', $collection::make(['string'])->flip());
378378

379-
assertType('Illuminate\Support\Collection<(int|string), array<User>>', $collection->groupBy('name'));
380-
assertType('Illuminate\Support\Collection<(int|string), array<User>>', $collection->groupBy('name', true));
381-
assertType('Illuminate\Support\Collection<(int|string), array<User>>', $collection->groupBy(function ($user, $int) {
379+
assertType('Illuminate\Support\Collection<(int|string), Illuminate\Support\Collection<(int|string), User>>', $collection->groupBy('name'));
380+
assertType('Illuminate\Support\Collection<(int|string), Illuminate\Support\Collection<(int|string), User>>', $collection->groupBy('name', true));
381+
assertType('Illuminate\Support\Collection<(int|string), Illuminate\Support\Collection<(int|string), User>>', $collection->groupBy(function ($user, $int) {
382382
// assertType('User', $user);
383383
// assertType('int', $int);
384384

385385
return 'foo';
386386
}));
387-
assertType('Illuminate\Support\Collection<(int|string), array<User>>', $collection->groupBy(function ($user) {
387+
assertType('Illuminate\Support\Collection<(int|string), Illuminate\Support\Collection<(int|string), User>>', $collection->groupBy(function ($user) {
388388
return 'foo';
389389
}));
390390

types/Support/LazyCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@
376376

377377
assertType('Illuminate\Support\LazyCollection<string, int>', $collection::make(['string'])->flip());
378378

379-
assertType('Illuminate\Support\LazyCollection<(int|string), array<User>>', $collection->groupBy('name'));
380-
assertType('Illuminate\Support\LazyCollection<(int|string), array<User>>', $collection->groupBy('name', true));
381-
assertType('Illuminate\Support\LazyCollection<(int|string), array<User>>', $collection->groupBy(function ($user, $int) {
379+
assertType('Illuminate\Support\LazyCollection<(int|string), Illuminate\Support\LazyCollection<(int|string), User>>', $collection->groupBy('name'));
380+
assertType('Illuminate\Support\LazyCollection<(int|string), Illuminate\Support\LazyCollection<(int|string), User>>', $collection->groupBy('name', true));
381+
assertType('Illuminate\Support\LazyCollection<(int|string), Illuminate\Support\LazyCollection<(int|string), User>>', $collection->groupBy(function ($user, $int) {
382382
// assertType('User', $user);
383383
// assertType('int', $int);
384384

385385
return 'foo';
386386
}));
387-
assertType('Illuminate\Support\LazyCollection<(int|string), array<User>>', $collection->groupBy(function ($user) {
387+
assertType('Illuminate\Support\LazyCollection<(int|string), Illuminate\Support\LazyCollection<(int|string), User>>', $collection->groupBy(function ($user) {
388388
return 'foo';
389389
}));
390390

0 commit comments

Comments
 (0)