diff --git a/tests/PHPStan/Analyser/nsrt/bug-10671.php b/tests/PHPStan/Analyser/nsrt/bug-10671.php index 33fdfb3a6d..06b36090ad 100644 --- a/tests/PHPStan/Analyser/nsrt/bug-10671.php +++ b/tests/PHPStan/Analyser/nsrt/bug-10671.php @@ -1,4 +1,6 @@ -= 8.0 + +declare(strict_types=1); namespace Bug10671; diff --git a/tests/PHPStan/Analyser/nsrt/bug-10671b.php b/tests/PHPStan/Analyser/nsrt/bug-10671b.php new file mode 100644 index 0000000000..1556c787d2 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/bug-10671b.php @@ -0,0 +1,50 @@ + assertType('list', $args) +); + +// Anonymous function with variadic - works correctly +callClosure( + function (...$args) { + assertType('list', $args); + } +); + +// Arrow function with typed variadic +callClosure( + fn(int ...$args) => assertType('list', $args) +); + +// Arrow function with variadic and preceding params +/** + * @param Closure(string, mixed...): mixed $closure + */ +function callClosure2(Closure $closure): void +{ +} + +callClosure2( + fn(string $first, ...$rest) => assertType('list', $rest) +); + +callClosure2( + function (string $first, ...$rest) { + assertType('list', $rest); + } +);