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
Passing class-string-map to variadic crashes psalm #5434
Comments
I found these snippets: https://psalm.dev/r/93f8d3fbc4<?php
class A {}
/** @param array<array-key, mixed> $args */
function takesVariadic(...$args): void {
}
/** @var class-string-map<A, A> */
$map = [A::class => new A()];
takesVariadic(...$map);
|
So the issue is here, and the I was thinking about adding a Would it be a good idea to add support for |
I found these snippets: https://psalm.dev/r/23869e7fec<?php
/**
* @psalm-suppress UnusedParam
* @param non-empty-array<string, string> $arg
*/
function test(array $arg): void {}
/** @var array{a?: string, b: string} */
$a = ['b' => 'b'];
test($a); // 'b' is required, $a should be non-empty-array
/** @var array{a: string, b?: string} */
$b = ['a' => 'a'];
test($b); // works
|
I think it might be useful to have an alias of all the possible array types for such situations (all types where the |
https://psalm.dev/r/93f8d3fbc4
The text was updated successfully, but these errors were encountered: