From 8db6921f1c1f84eb0b0c6064cc9ba023aacce116 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 24 Feb 2017 21:27:52 -0500 Subject: [PATCH] More graceful early exit if not checking variables --- .../Checker/Statements/ExpressionChecker.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Checker/Statements/ExpressionChecker.php b/src/Psalm/Checker/Statements/ExpressionChecker.php index 6a6fba246..ced45b791 100644 --- a/src/Psalm/Checker/Statements/ExpressionChecker.php +++ b/src/Psalm/Checker/Statements/ExpressionChecker.php @@ -477,11 +477,18 @@ class ExpressionChecker } if (!$context->check_variables) { - $stmt->inferredType = Type::getMixed(); + if (is_string($stmt->name)) { + $var_name = '$' . $stmt->name; - if (is_string($stmt->name) && !$context->hasVariable('$' . $stmt->name)) { - $context->vars_in_scope['$' . $stmt->name] = Type::getMixed(); - $context->vars_possibly_in_scope['$' . $stmt->name] = true; + if (!$context->hasVariable($var_name)) { + $context->vars_in_scope[$var_name] = Type::getMixed(); + $context->vars_possibly_in_scope[$var_name] = true; + $stmt->inferredType = Type::getMixed(); + } else { + $stmt->inferredType = $context->vars_in_scope[$var_name]; + } + } else { + $stmt->inferredType = Type::getMixed(); } return null;