From e663c1da193544f828c08ace07b9ea6df1b42aab Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Mon, 12 Sep 2016 00:01:47 -0400 Subject: [PATCH] Add support for object negation --- src/Psalm/Checker/TypeChecker.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Psalm/Checker/TypeChecker.php b/src/Psalm/Checker/TypeChecker.php index 37e288e08..ea1d34dae 100644 --- a/src/Psalm/Checker/TypeChecker.php +++ b/src/Psalm/Checker/TypeChecker.php @@ -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');