1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix interface extends return types

This commit is contained in:
Matthew Brown 2016-10-25 11:20:06 -04:00
parent 6dde59bd20
commit 694d159829
3 changed files with 7 additions and 1 deletions

View File

@ -85,6 +85,11 @@ class InterfaceChecker extends ClassLikeChecker
self::$existing_interfaces_ci = [];
}
public static function interfaceExtends($interface_name, $possible_parent)
{
return in_array($possible_parent, self::getParentInterfaces($interface_name));
}
/**
* @param string $interface_name
* @return array<string> all interfaces extended by $interface_name

View File

@ -492,7 +492,7 @@ class MethodChecker extends FunctionLikeChecker
}
}
if (ClassChecker::classExtends($method_class, $calling_context) && method_exists($calling_context, $method_name)) {
if (ClassChecker::classExtends($method_class, $calling_context) && MethodChecker::methodExists($calling_context . '::' . $method_name)) {
return;
}

View File

@ -1248,6 +1248,7 @@ class TypeChecker
if ($simple_declared_type === 'mixed'
|| ($simple_declared_type === 'object' && ClassLikeChecker::classOrInterfaceExists($differing_type))
|| ClassChecker::classExtendsOrImplements($differing_type, $simple_declared_type)
|| (InterfaceChecker::interfaceExists($differing_type) && InterfaceChecker::interfaceExtends($differing_type, $simple_declared_type))
|| (in_array($differing_type, ['array', 'object-like']) && in_array($simple_declared_type, ['array', 'object-like']))
|| (in_array($differing_type, ['float', 'int']) && in_array($simple_declared_type, ['float', 'int']))
) {