Skip to content

Commit fe0d9a5

Browse files
authored
Improve psalm types in ArrayHelper::group() (#171)
1 parent f846c6e commit fe0d9a5

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Enh #168: Add benchmark, improve `ArrayHelper::htmlEncode()` performance (@samdark)
66
- Enh #169: Bump `yiisoft/strings` dependency to `^2.6` (@vjik)
7+
- Enh #171: Improve psalm types in `ArrayHelper::group()` (@vjik)
78

89
## 3.2.0 February 01, 2025
910

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
},
3434
"require-dev": {
3535
"bamarni/composer-bin-plugin": "^1.8.2",
36-
"phpunit/phpunit": "^10.5.45",
37-
"rector/rector": "^2.0.9",
36+
"phpunit/phpunit": "^10.5.48",
37+
"rector/rector": "^2.1.2",
3838
"roave/infection-static-analysis-plugin": "^1.35",
3939
"spatie/phpunit-watcher": "^1.24",
4040
"vimeo/psalm": "^5.26.1 || ^6.5.1",
41-
"phpbench/phpbench": "^1.4"
41+
"phpbench/phpbench": "^1.4.1"
4242
},
4343
"autoload": {
4444
"psr-4": {
@@ -52,7 +52,6 @@
5252
},
5353
"config": {
5454
"sort-packages": true,
55-
"bump-after-update": "dev",
5655
"allow-plugins": {
5756
"bamarni/composer-bin-plugin": true,
5857
"infection/extension-installer": true,

src/ArrayHelper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,15 @@ public static function index(
797797
* @param Closure[]|string|string[] $groups The array of keys that will be used to group the input array
798798
* by one or more keys.
799799
*
800-
* @psalm-param iterable<mixed, array|object> $array
801-
*
802800
* @return array The grouped array.
801+
*
802+
* @template T as array|object
803+
* @psalm-param iterable<mixed, T> $array
804+
* @psalm-return array<non-empty-list<T>>
803805
*/
804806
public static function group(iterable $array, array|string $groups): array
805807
{
808+
/** @psalm-var array<non-empty-list<T>> */
806809
return self::index($array, null, $groups);
807810
}
808811

0 commit comments

Comments
 (0)