Skip to content

Commit

Permalink
Remove mixed assignment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 7, 2020
1 parent 95f7a47 commit 57397c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Psalm/Internal/Analyzer/Statements/Block/IfAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,33 @@ protected static function analyzeIfBlock(
);
}

foreach ($changed_var_ids as $var_id => $_) {
$first_appearance = $statements_analyzer->getFirstAppearance($var_id);

if ($first_appearance
&& isset($outer_context->vars_in_scope[$var_id])
&& isset($outer_context_vars_reconciled[$var_id])
&& $outer_context->vars_in_scope[$var_id]->hasMixed()
&& !$outer_context_vars_reconciled[$var_id]->hasMixed()
) {
if (!$outer_context->collect_initializations
&& !$outer_context->collect_mutations
&& $statements_analyzer->getFilePath() === $statements_analyzer->getRootFilePath()
&& (!(($parent_source = $statements_analyzer->getSource())
instanceof \Psalm\Internal\Analyzer\FunctionLikeAnalyzer)
|| !$parent_source->getSource() instanceof \Psalm\Internal\Analyzer\TraitAnalyzer)
) {
$codebase->analyzer->decrementMixedCount($statements_analyzer->getFilePath());
}

IssueBuffer::remove(
$statements_analyzer->getFilePath(),
'MixedAssignment',
$first_appearance->raw_file_start
);
}
}

$outer_context->vars_in_scope = $outer_context_vars_reconciled;
$mic_drop = true;
}
Expand Down

0 comments on commit 57397c9

Please sign in to comment.