1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 09:19:40 +01:00

Add return type checking of object-like types

This commit is contained in:
Matthew Brown 2016-10-03 16:40:02 -04:00
parent efb7cd8218
commit b8ba6ffbf6

View File

@ -1089,6 +1089,33 @@ class TypeChecker
return false; return false;
} }
} }
}
foreach ($declared_type->types as $key => $declared_atomic_type) {
if (!isset($inferred_type->types[$key])) {
continue;
}
$inferred_atomic_type = $inferred_type->types[$key];
if (!($declared_atomic_type instanceof Type\ObjectLike)) {
continue;
}
if (!($inferred_atomic_type instanceof Type\ObjectLike)) {
// @todo handle this better
continue;
}
foreach ($declared_atomic_type->properties as $property_name => $type_param) {
if (!isset($inferred_atomic_type->properties[$property_name])) {
return false;
}
if (!self::hasIdenticalTypes($type_param, $inferred_atomic_type->properties[$property_name], $absolute_class)) {
return false;
}
}
} }