Skip to content
Permalink
Browse files

Ensure that properties not set on class add back to context (as mixed)

  • Loading branch information...
muglug committed Sep 8, 2019
1 parent 85ae8f9 commit b7f79b547e78838a7c0f3f64180ead82f8858e89
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php
@@ -1304,7 +1304,17 @@ function (PhpParser\Node\Arg $arg) {
$context->removeAllObjectVars();
} elseif ($method_storage->this_property_mutations) {
foreach ($method_storage->this_property_mutations as $name => $_) {
$context->remove($lhs_var_id . '->' . $name);
$mutation_var_id = $lhs_var_id . '->' . $name;
$this_property_didnt_exist = $lhs_var_id === '$this'
&& isset($context->vars_in_scope[$mutation_var_id])
&& !isset($class_storage->declaring_property_ids[$name]);
$context->remove($mutation_var_id);
if ($this_property_didnt_exist) {
$context->vars_in_scope[$mutation_var_id] = Type::getMixed();
}
}
}
}

0 comments on commit b7f79b5

Please sign in to comment.
You can’t perform that action at this time.