1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Allow nullable method return types

This commit is contained in:
Matthew Brown 2016-12-04 00:08:25 -05:00
parent d7c6e84a0d
commit 983c6fd6c4

View File

@ -312,14 +312,24 @@ class MethodChecker extends FunctionLikeChecker
self::$method_suppress[$method_id] = [];
if (isset($method->returnType)) {
$parser_return_type = $method->returnType;
$suffix = '';
if ($parser_return_type instanceof PhpParser\Node\NullableType) {
$suffix = '|null';
$parser_return_type = $parser_return_type->type;
}
$return_type = Type::parseString(
is_string($method->returnType)
? $method->returnType
(is_string($parser_return_type)
? $parser_return_type
: ClassLikeChecker::getFQCLNFromNameObject(
$method->returnType,
$parser_return_type,
$this->namespace,
$this->getAliasedClasses()
)
) . $suffix
);
}