diff --git a/src/Psalm/Checker/InterfaceChecker.php b/src/Psalm/Checker/InterfaceChecker.php index bbae84d2e..c72e77239 100644 --- a/src/Psalm/Checker/InterfaceChecker.php +++ b/src/Psalm/Checker/InterfaceChecker.php @@ -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 all interfaces extended by $interface_name diff --git a/src/Psalm/Checker/MethodChecker.php b/src/Psalm/Checker/MethodChecker.php index 612865ccc..be05d73d8 100644 --- a/src/Psalm/Checker/MethodChecker.php +++ b/src/Psalm/Checker/MethodChecker.php @@ -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; } diff --git a/src/Psalm/Checker/TypeChecker.php b/src/Psalm/Checker/TypeChecker.php index 5c38081ec..bb99216c1 100644 --- a/src/Psalm/Checker/TypeChecker.php +++ b/src/Psalm/Checker/TypeChecker.php @@ -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'])) ) {