-
Notifications
You must be signed in to change notification settings - Fork 663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intersection types don't allow arrays #7600
Comments
I found these snippets: https://psalm.dev/r/125b383b8b<?php
/**
* @template T as array
* @param T $i
* @return T&array{test1: "test"}
*/
function enhance(array $i): array {
$i['i'] = 'test';
return $i;
}
|
This is just missing support for intersections between templates and keyed array. The intersection in itself is ok: https://psalm.dev/r/9384c60365 This should probably not be hard to fix and we have one or two similar issues (intersection with aliased types) |
I found these snippets: https://psalm.dev/r/9384c60365<?php
/**
* @template T as array
* @param T $i
* @return array&array{test1: "test"}
*/
function enhance(array $i): array {
$i['i'] = 'test';
return $i;
}
|
Especially with v5 unsealed arrays and restrictReturnTypes this is a more common issue now |
It seems this worked previously? #3064 |
I find it often useful to use intersection types to enhance the keys of an array, but psalm doesn't like it: https://psalm.dev/r/125b383b8b
The text was updated successfully, but these errors were encountered: