|
2 | 2 |
|
3 | 3 | namespace PHPStan\Type\Php; |
4 | 4 |
|
| 5 | +use PhpParser\Node\Param; |
5 | 6 | use PhpParser\Node\Expr; |
6 | 7 | use PhpParser\Node\Expr\FuncCall; |
| 8 | +use PhpParser\Node\Expr\Variable; |
7 | 9 | use PHPStan\Analyser\Scope; |
8 | 10 | use PHPStan\Analyser\SpecifiedTypes; |
9 | 11 | use PHPStan\Analyser\TypeSpecifier; |
@@ -53,12 +55,20 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n |
53 | 55 | $callableParms = $callable->params; |
54 | 56 | $specifiedTypesInFuncCall = $this->typeSpecifier->specifyTypesInCondition($scope, $callable->expr, $context)->getSureTypes(); |
55 | 57 |
|
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); |
58 | 64 | } |
59 | 65 |
|
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); |
62 | 72 | } |
63 | 73 |
|
64 | 74 | if (isset($keyType) || isset($valueType)) { |
|
0 commit comments