Skip to content

Commit edc43c4

Browse files
adaamzondrejmirtes
authored andcommitted
Call Component::GetPresenter without parameters throws exception in new Nette (non-null return type)
1 parent 2777e1c commit edc43c4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Type/Nette/ComponentGetPresenterDynamicReturnTypeExtension.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2626

2727
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
2828
{
29-
$defaultReturnType = ParametersAcceptorSelector::selectSingle(
29+
$methodDefinition = ParametersAcceptorSelector::selectSingle(
3030
$methodReflection->getVariants()
31-
)->getReturnType();
31+
);
32+
$defaultReturnType = $methodDefinition->getReturnType();
33+
$firstParameterExists = count($methodDefinition->getParameters()) > 0;
34+
3235
if (count($methodCall->args) < 1) {
36+
if (!$firstParameterExists) {
37+
return TypeCombinator::removeNull($defaultReturnType);
38+
}
39+
3340
return $defaultReturnType;
3441
}
3542

0 commit comments

Comments
 (0)