File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1- <?php declare (strict_types=1 );
1+ <?php // lint >= 8.0
2+
3+ declare (strict_types=1 );
24
35namespace Bug10671 ;
46
Original file line number Diff line number Diff line change 1+ <?php // lint < 8.0
2+
3+ declare (strict_types=1 );
4+
5+ namespace Bug10671b ;
6+
7+ use Closure ;
8+ use function PHPStan \Testing \assertType ;
9+
10+ /**
11+ * @param Closure(mixed...): mixed $closure
12+ */
13+ function callClosure (Closure $ closure ): void
14+ {
15+ }
16+
17+ // Arrow function with variadic - the bug
18+ callClosure (
19+ fn (...$ args ) => assertType ('list ' , $ args )
20+ );
21+
22+ // Anonymous function with variadic - works correctly
23+ callClosure (
24+ function (...$ args ) {
25+ assertType ('list ' , $ args );
26+ }
27+ );
28+
29+ // Arrow function with typed variadic
30+ callClosure (
31+ fn (int ...$ args ) => assertType ('list<int> ' , $ args )
32+ );
33+
34+ // Arrow function with variadic and preceding params
35+ /**
36+ * @param Closure(string, mixed...): mixed $closure
37+ */
38+ function callClosure2 (Closure $ closure ): void
39+ {
40+ }
41+
42+ callClosure2 (
43+ fn (string $ first , ...$ rest ) => assertType ('list ' , $ rest )
44+ );
45+
46+ callClosure2 (
47+ function (string $ first , ...$ rest ) {
48+ assertType ('list ' , $ rest );
49+ }
50+ );
You can’t perform that action at this time.
0 commit comments