Skip to content

Commit

Permalink
Ensure that properties not set on class add back to context (as mixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Sep 8, 2019
1 parent 85ae8f9 commit b7f79b5
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}
Expand Down

0 comments on commit b7f79b5

Please sign in to comment.