|
10 | 10 | use PhpParser\Node\Expr\MethodCall; |
11 | 11 | use PhpParser\Node\Expr\StaticCall; |
12 | 12 | use PhpParser\Node\Identifier; |
| 13 | +use PhpParser\Node\VariadicPlaceholder; |
13 | 14 | use PHPStan\Reflection\ReflectionProvider; |
14 | 15 | use PHPStan\Type\ArrayType; |
15 | 16 | use PHPStan\Type\MixedType; |
@@ -39,16 +40,12 @@ public function resolveStrictTypesFromCalls(array $calls): array |
39 | 40 | $staticTypesByArgumentPosition = []; |
40 | 41 |
|
41 | 42 | foreach ($calls as $call) { |
42 | | - if ($call->isFirstClassCallable()) { |
43 | | - return []; |
44 | | - } |
45 | | - |
46 | 43 | foreach ($call->getArgs() as $position => $arg) { |
47 | | - /** @var Arg $arg */ |
48 | 44 | if ($this->shouldSkipArg($arg)) { |
49 | 45 | return []; |
50 | 46 | } |
51 | 47 |
|
| 48 | + /** @var Arg $arg */ |
52 | 49 | $staticTypesByArgumentPosition[$position][] = $this->resolveStrictArgValueType($arg); |
53 | 50 | } |
54 | 51 | } |
@@ -77,6 +74,7 @@ public function resolveTypesFromCalls(array $calls): array |
77 | 74 | continue; |
78 | 75 | } |
79 | 76 |
|
| 77 | + /** @var Arg $arg */ |
80 | 78 | $staticTypesByArgumentPosition[$position][] = $this->resolveArgValueType($arg); |
81 | 79 | } |
82 | 80 | } |
@@ -204,11 +202,15 @@ private function normalizeType(Type $argValueType): MixedType|ObjectType|Type |
204 | 202 | } |
205 | 203 |
|
206 | 204 | /** |
207 | | - * There is argument unpack, or named expr |
| 205 | + * There is first class callable usage, or argument unpack, or named expr |
208 | 206 | * simply returns array marks as unknown as can be anything and in any position |
209 | 207 | */ |
210 | | - private function shouldSkipArg(Arg $arg): bool |
| 208 | + private function shouldSkipArg(Arg|VariadicPlaceholder $arg): bool |
211 | 209 | { |
| 210 | + if ($arg instanceof VariadicPlaceholder) { |
| 211 | + return true; |
| 212 | + } |
| 213 | + |
212 | 214 | if ($arg->unpack) { |
213 | 215 | return true; |
214 | 216 | } |
|
0 commit comments