psalm
psalm copied to clipboard
Signature / return types are lost when creating a closure from known callable string
https://psalm.dev/r/73cab7cf3f
I found these snippets:
https://psalm.dev/r/73cab7cf3f
<?php
function f(mixed ...$_rest): string { return 'f'; }
class C {
public static function sm(mixed ...$_rest): string { return 'm'; }
}
$_f = 'C::sm'(...); /** @psalm-trace $_f */; /** @psalm-check-type $_f=callable(mixed...):string */;
$_f = 'f'(...); /** @psalm-trace $_f */; /** @psalm-check-type $_f=callable(mixed...):string */;
Psalm output (using commit bf57d59):
INFO: Trace - 8:44 - $_f: Closure
ERROR: CheckType - 8:100 - Checked variable $_f = callable(mixed...):string does not match $_f = Closure
INFO: Trace - 9:40 - $_f: Closure
ERROR: CheckType - 9:96 - Checked variable $_f = callable(mixed...):string does not match $_f = Closure