diff --git a/src/ReturnTypeExtension/NodeGetAttributeTypeExtension.php b/src/ReturnTypeExtension/NodeGetAttributeTypeExtension.php index dad02bc4..a52e873e 100644 --- a/src/ReturnTypeExtension/NodeGetAttributeTypeExtension.php +++ b/src/ReturnTypeExtension/NodeGetAttributeTypeExtension.php @@ -51,18 +51,16 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope - ): Type { - $returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType(); - + ): ?Type { $firstArg = $methodCall->getArgs()[0]; $argumentValue = $this->resolveArgumentValue($firstArg->value); if ($argumentValue === null) { - return $returnType; + return null; } if (! isset(self::ARGUMENT_KEY_TO_RETURN_TYPE[$argumentValue])) { - return $returnType; + return null; } $knownReturnType = self::ARGUMENT_KEY_TO_RETURN_TYPE[$argumentValue];