psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Signature / return types are lost when creating a closure from known callable string

Open weirdan opened this issue 1 year ago • 1 comments

https://psalm.dev/r/73cab7cf3f

weirdan avatar Jan 31 '24 23:01 weirdan

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

psalm-github-bot[bot] avatar Jan 31 '24 23:01 psalm-github-bot[bot]