Given this code:
/**
* @psalm-param array<array-key, string> $bars
*/
function foo(array $bars): void
{
}
class Bar {
public function __toString()
{
return 'bar';
}
}
foo([new Bar()]);
I'd expect an ImplicitToStringCast error to be emitted. But it doesn't.
After changing the array to a list, however, the error will be emitted
/**
* @psalm-param list<string> $bars
*/
function foo(array $bars): void
{
}
class Bar {
public function __toString()
{
return 'bar';
}
}
foo([new Bar()]);
https://psalm.dev/r/ee207d52b3