1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add support for object negation

This commit is contained in:
Matthew Brown 2016-09-12 00:01:47 -04:00
parent 564c4e2bf3
commit e663c1da19

View File

@ -815,6 +815,20 @@ class TypeChecker
}
if ($new_var_type[0] === '!') {
if ($new_var_type === '!object' && !$existing_var_type->isMixed()) {
$non_object_types = [];
foreach ($existing_var_type->types as $type) {
if (!$type->isObjectType()) {
$non_object_types[] = $type;
}
}
if ($non_object_types) {
return new Type\Union($non_object_types);
}
}
if (in_array($new_var_type, ['!empty', '!null'])) {
$existing_var_type->removeType('null');