diff --git a/src/Psalm/Checker/FunctionChecker.php b/src/Psalm/Checker/FunctionChecker.php index 15b3df377..ad24dae35 100644 --- a/src/Psalm/Checker/FunctionChecker.php +++ b/src/Psalm/Checker/FunctionChecker.php @@ -494,7 +494,7 @@ class FunctionChecker extends FunctionLikeChecker } } elseif ($first_arg->inferredType->hasScalarType() && ($second_arg = $call_args[1]->value) && - $second_arg->inferredType && + isset($second_arg->inferredType) && $second_arg->inferredType->hasScalarType() ) { return Type::combineUnionTypes($first_arg->inferredType, $second_arg->inferredType); diff --git a/src/Psalm/Checker/MethodChecker.php b/src/Psalm/Checker/MethodChecker.php index 41a0e520e..757a0bf30 100644 --- a/src/Psalm/Checker/MethodChecker.php +++ b/src/Psalm/Checker/MethodChecker.php @@ -504,7 +504,9 @@ class MethodChecker extends FunctionLikeChecker $old_method_id = null; - ClassLikeChecker::registerClass($method_parts[0]); + if (ClassLikeChecker::registerClass($method_parts[0]) === false) { + return false; + } $class_storage = ClassLikeChecker::$storage[$method_parts[0]]; diff --git a/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php b/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php index 1392fa7be..d8f246916 100644 --- a/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php +++ b/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php @@ -422,7 +422,7 @@ class AssignmentChecker continue; } - if (MethodChecker::methodExists($lhs_type_part . '::__set')) { + if (!$lhs_type_part->isObject() && MethodChecker::methodExists($lhs_type_part . '::__set')) { $context->vars_in_scope[$var_id] = Type::getMixed(); continue; } diff --git a/src/Psalm/Checker/TraitChecker.php b/src/Psalm/Checker/TraitChecker.php index bc43ad529..bfd66a6f8 100644 --- a/src/Psalm/Checker/TraitChecker.php +++ b/src/Psalm/Checker/TraitChecker.php @@ -123,7 +123,10 @@ class TraitChecker extends ClassLikeChecker return self::$existing_traits[strtolower($trait_name)]; } + $old_level = error_reporting(); + error_reporting(0); $trait_exists = trait_exists($trait_name); + error_reporting($old_level); self::$existing_traits[strtolower($trait_name)] = $trait_exists; diff --git a/src/Psalm/Checker/TypeChecker.php b/src/Psalm/Checker/TypeChecker.php index dcd95f19a..b2b45b2e1 100644 --- a/src/Psalm/Checker/TypeChecker.php +++ b/src/Psalm/Checker/TypeChecker.php @@ -757,7 +757,7 @@ class TypeChecker $type_match_found = true; } - if ($container_type_part->isString() && $input_type_part->isObjectType()) { + if ($container_type_part->isString() && $input_type_part->isObjectType() && !$input_type_part->isObject()) { // check whether the object has a __toString method if (MethodChecker::methodExists($input_type_part->value . '::__toString')) { $type_match_found = true; diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index ef7927d69..816036132 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -58,7 +58,7 @@ class Atomic extends Type if (isset($aliased_classes[strtolower($this->value)])) { return $aliased_classes[strtolower($this->value)]; } - + return '\\' . $this->value; } @@ -182,6 +182,7 @@ class Atomic extends Type && !$this->isEmpty() && !$this->isResource() && !$this->isIterable() + && !$this->isScalar() ); }