Skip to content

Commit 6b3eb45

Browse files
committed
Fix phpstan
1 parent 81d62d8 commit 6b3eb45

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpParser\Node\Expr\MethodCall;
1111
use PhpParser\Node\Expr\StaticCall;
1212
use PhpParser\Node\Identifier;
13+
use PhpParser\Node\VariadicPlaceholder;
1314
use PHPStan\Reflection\ReflectionProvider;
1415
use PHPStan\Type\ArrayType;
1516
use PHPStan\Type\MixedType;
@@ -39,16 +40,12 @@ public function resolveStrictTypesFromCalls(array $calls): array
3940
$staticTypesByArgumentPosition = [];
4041

4142
foreach ($calls as $call) {
42-
if ($call->isFirstClassCallable()) {
43-
return [];
44-
}
45-
4643
foreach ($call->getArgs() as $position => $arg) {
47-
/** @var Arg $arg */
4844
if ($this->shouldSkipArg($arg)) {
4945
return [];
5046
}
5147

48+
/** @var Arg $arg */
5249
$staticTypesByArgumentPosition[$position][] = $this->resolveStrictArgValueType($arg);
5350
}
5451
}
@@ -77,6 +74,7 @@ public function resolveTypesFromCalls(array $calls): array
7774
continue;
7875
}
7976

77+
/** @var Arg $arg */
8078
$staticTypesByArgumentPosition[$position][] = $this->resolveArgValueType($arg);
8179
}
8280
}
@@ -204,11 +202,15 @@ private function normalizeType(Type $argValueType): MixedType|ObjectType|Type
204202
}
205203

206204
/**
207-
* There is argument unpack, or named expr
205+
* There is first class callable usage, or argument unpack, or named expr
208206
* simply returns array marks as unknown as can be anything and in any position
209207
*/
210-
private function shouldSkipArg(Arg $arg): bool
208+
private function shouldSkipArg(Arg|VariadicPlaceholder $arg): bool
211209
{
210+
if ($arg instanceof VariadicPlaceholder) {
211+
return true;
212+
}
213+
212214
if ($arg->unpack) {
213215
return true;
214216
}

0 commit comments

Comments
 (0)