1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Use mixed type if we detect expression error

This commit is contained in:
Matthew Brown 2016-06-20 18:10:55 -04:00
parent 162a8a2c2b
commit 6f9cb1d99c

View File

@ -1476,7 +1476,12 @@ class StatementsChecker
protected function _checkAssignment(PhpParser\Node\Expr\Assign $stmt, Context $context) protected function _checkAssignment(PhpParser\Node\Expr\Assign $stmt, Context $context)
{ {
$var_id = self::getVarId($stmt->var);
if ($this->_checkExpression($stmt->expr, $context) === false) { if ($this->_checkExpression($stmt->expr, $context) === false) {
// if we're not exiting immediately, make everything mixed
$context->vars_in_scope[$var_id] = Type::getMixed();
return false; return false;
} }
@ -1506,8 +1511,6 @@ class StatementsChecker
} }
} }
$var_id = self::getVarId($stmt->var);
if ($type_in_comments_var_id && $type_in_comments_var_id !== $var_id) { if ($type_in_comments_var_id && $type_in_comments_var_id !== $var_id) {
if (isset($context->vars_in_scope[$type_in_comments_var_id])) { if (isset($context->vars_in_scope[$type_in_comments_var_id])) {
$context->vars_in_scope[$type_in_comments_var_id] = Type::parseString($type_in_comments); $context->vars_in_scope[$type_in_comments_var_id] = Type::parseString($type_in_comments);