Skip to content

Commit 865e508

Browse files
uekannuekann
authored andcommitted
Fix condition
1 parent 8fe7a3a commit 865e508

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Type/Php/ArrayAllFunctionTypeSpecifyingExtension.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace PHPStan\Type\Php;
44

5+
use PhpParser\Node\Param;
56
use PhpParser\Node\Expr;
67
use PhpParser\Node\Expr\FuncCall;
8+
use PhpParser\Node\Expr\Variable;
79
use PHPStan\Analyser\Scope;
810
use PHPStan\Analyser\SpecifiedTypes;
911
use PHPStan\Analyser\TypeSpecifier;
@@ -53,12 +55,20 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n
5355
$callableParms = $callable->params;
5456
$specifiedTypesInFuncCall = $this->typeSpecifier->specifyTypesInCondition($scope, $callable->expr, $context)->getSureTypes();
5557

56-
if (isset($callableParms[0]) && $callableParms[0] instanceof Expr\Variable) {
57-
$valueType = $this->fetchTypeByVariable($specifiedTypesInFuncCall, $callableParms[0]->name);
58+
if (
59+
isset($callableParms[0]) &&
60+
$callableParms[0] instanceof Param &&
61+
$callableParms[0]->var instanceof Variable
62+
) {
63+
$valueType = $this->fetchTypeByVariable($specifiedTypesInFuncCall, $callableParms[0]->var->name);
5864
}
5965

60-
if (isset($callableParms[1]) && $callableParms[1] instanceof Expr\Variable) {
61-
$keyType = $this->fetchTypeByVariable($specifiedTypesInFuncCall, $callableParms[1]->name);
66+
if (
67+
isset($callableParms[1]) &&
68+
$callableParms[1] instanceof Param &&
69+
$callableParms[1]->var instanceof Variable
70+
) {
71+
$keyType = $this->fetchTypeByVariable($specifiedTypesInFuncCall, $callableParms[1]->var->name);
6272
}
6373

6474
if (isset($keyType) || isset($valueType)) {

0 commit comments

Comments
 (0)