Skip to content

Commit 15bb297

Browse files
committed
Fixed build
1 parent ecab3bd commit 15bb297

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Type/Nette/ComponentLookupDynamicReturnTypeExtension.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node\Expr\MethodCall;
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\MethodReflection;
8+
use PHPStan\Reflection\ParametersAcceptorSelector;
89
use PHPStan\Type\Constant\ConstantBooleanType;
910
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1011
use PHPStan\Type\Type;
@@ -25,22 +26,25 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2526

2627
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
2728
{
29+
$defaultReturnType = ParametersAcceptorSelector::selectSingle(
30+
$methodReflection->getVariants()
31+
)->getReturnType();
2832
if (count($methodCall->args) < 2) {
29-
return $methodReflection->getReturnType();
33+
return $defaultReturnType;
3034
}
3135

3236
$paramNeedExpr = $methodCall->args[1]->value;
3337
$paramNeedType = $scope->getType($paramNeedExpr);
3438

3539
if ($paramNeedType instanceof ConstantBooleanType) {
3640
if ($paramNeedType->getValue()) {
37-
return TypeCombinator::removeNull($methodReflection->getReturnType());
41+
return TypeCombinator::removeNull($defaultReturnType);
3842
}
3943

40-
return TypeCombinator::addNull($methodReflection->getReturnType());
44+
return TypeCombinator::addNull($defaultReturnType);
4145
}
4246

43-
return $methodReflection->getReturnType();
47+
return $defaultReturnType;
4448
}
4549

4650
}

0 commit comments

Comments
 (0)