Psalm
Get started
Documentation
Paid support
Plugins
Blog
GitHub
<?php function withVariadicParam(int $a, int $b, int ...$rest): int { throw new RuntimeException(); } /** @param Closure(int, int): int $f */ function int_int(Closure $f): void {} /** @param Closure(int, int, int): int $f */ function int_int_int(Closure $f): void {} /** @param Closure(int, int, int, int): int $f */ function int_int_int_int(Closure $f): void {} /** @param Closure(int, int, int, string): int $f */ function int_int_int_string(Closure $f): void {} // false positive: expected no issues here int_int(withVariadicParam(...)); // ok: but that's because the number of parameters are the same. int_int_int(withVariadicParam(...)); // ok: but last param actually does not type checked. int_int_int_int(withVariadicParam(...)); // false negative: expected issue here int_int_int_string(withVariadicParam(...));
Snippet created on July 29 2023 at 18:16 UTC
Settings
Get link