mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-02 09:38:32 +01:00
[Arr] group_by: throw when $key_fun returns a non-arraykey type
This commit is contained in:
parent
c5400a8571
commit
7c904b60e8
@ -45,6 +45,8 @@ function group_by(iterable $values, callable $key_func): array
|
||||
continue;
|
||||
}
|
||||
|
||||
Psl\invariant(is_arraykey($key), 'Expected $key_func to return a value of type array-key, value of type (%s) returned.', gettype($key));
|
||||
/** @psalm-var Tk $key */
|
||||
$result[$key] = $result[$key] ?? [];
|
||||
$result[$key][] = $value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user