Skip to content

Commit c39f3ec

Browse files
authored
Fix build
1 parent 1f6cf23 commit c39f3ec

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

tests/PHPStan/Analyser/nsrt/bug-10671.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php // lint >= 8.0
2+
3+
declare(strict_types=1);
24

35
namespace Bug10671;
46

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
);

0 commit comments

Comments
 (0)