Skip to content

Commit 465044f

Browse files
authored
Fix incorrect PHPDoc for KeyBy and GroupBy (#52918)
1 parent f205537 commit 465044f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Collection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public function getOrPut($key, $value)
490490
*
491491
* @param (callable(TValue, TKey): TGroupKey)|array|string $groupBy
492492
* @param bool $preserveKeys
493-
* @return static<TGroupKey, static<($preserveKeys is true ? TKey : int), TValue>>
493+
* @return static<($groupBy is string ? array-key : ($groupBy is array ? array-key : TGroupKey)), static<($preserveKeys is true ? TKey : int), TValue>>
494494
*/
495495
public function groupBy($groupBy, $preserveKeys = false)
496496
{
@@ -542,7 +542,7 @@ public function groupBy($groupBy, $preserveKeys = false)
542542
* @template TNewKey of array-key
543543
*
544544
* @param (callable(TValue, TKey): TNewKey)|array|string $keyBy
545-
* @return static<TNewKey, TValue>
545+
* @return static<($keyBy is string ? array-key : ($keyBy is array ? array-key : TNewKey)), TValue>
546546
*/
547547
public function keyBy($keyBy)
548548
{

Enumerable.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ public function get($key, $default = null);
522522
*
523523
* @param (callable(TValue, TKey): TGroupKey)|array|string $groupBy
524524
* @param bool $preserveKeys
525-
* @return static<TGroupKey, static<($preserveKeys is true ? TKey : int), TValue>>
525+
* @return static<($groupBy is string ? array-key : ($groupBy is array ? array-key : TGroupKey)), static<($preserveKeys is true ? TKey : int), TValue>>
526526
*/
527527
public function groupBy($groupBy, $preserveKeys = false);
528528

@@ -532,7 +532,7 @@ public function groupBy($groupBy, $preserveKeys = false);
532532
* @template TNewKey of array-key
533533
*
534534
* @param (callable(TValue, TKey): TNewKey)|array|string $keyBy
535-
* @return static<TNewKey, TValue>
535+
* @return static<($keyBy is string ? array-key : ($keyBy is array ? array-key : TNewKey)), TValue>
536536
*/
537537
public function keyBy($keyBy);
538538

LazyCollection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public function get($key, $default = null)
548548
*
549549
* @param (callable(TValue, TKey): TGroupKey)|array|string $groupBy
550550
* @param bool $preserveKeys
551-
* @return static<TGroupKey, static<($preserveKeys is true ? TKey : int), TValue>>
551+
* @return static<($groupBy is string ? array-key : ($groupBy is array ? array-key : TGroupKey)), static<($preserveKeys is true ? TKey : int), TValue>>
552552
*/
553553
public function groupBy($groupBy, $preserveKeys = false)
554554
{
@@ -561,7 +561,7 @@ public function groupBy($groupBy, $preserveKeys = false)
561561
* @template TNewKey of array-key
562562
*
563563
* @param (callable(TValue, TKey): TNewKey)|array|string $keyBy
564-
* @return static<TNewKey, TValue>
564+
* @return static<($keyBy is string ? array-key : ($keyBy is array ? array-key : TNewKey)), TValue>
565565
*/
566566
public function keyBy($keyBy)
567567
{

0 commit comments

Comments
 (0)