-
-
Notifications
You must be signed in to change notification settings - Fork 943
Closed
Labels
Milestone
Description
It should be possible to "extend" (of) Arrays. Use case:
/**
* @template T of array
* @param T $arr
* @return T & array{mykey: int}
*/
function addSomeKey(array $arr, int $value): array {
$arr['mykey'] = $value;
return $arr;
}Playground: https://phpstan.org/r/2a391b38-912d-4ea5-a71a-a1fab833d2f8
Right now, this produces multiple errors, the root problem being:
PHPDoc tag @template T for function addSomeKey() with bound type array is not supported.
Reactions are currently unavailable