mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Increase type coverage for projects that use assert after mixed
This commit is contained in:
parent
c5319fc379
commit
da5e8a4324
@ -850,7 +850,19 @@ class FunctionCallAnalyzer extends CallAnalyzer
|
||||
);
|
||||
|
||||
foreach ($changed_var_ids as $var_id => $_) {
|
||||
if ($first_appearance = $statements_analyzer->getFirstAppearance($var_id)) {
|
||||
$first_appearance = $statements_analyzer->getFirstAppearance($var_id);
|
||||
|
||||
if ($first_appearance && $context->vars_in_scope[$var_id]->hasMixed()) {
|
||||
if (!$context->collect_initializations
|
||||
&& !$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',
|
||||
|
@ -3806,7 +3806,21 @@ class CallAnalyzer
|
||||
|
||||
foreach ($changed_var_ids as $var_id => $_) {
|
||||
if (isset($op_vars_in_scope[$var_id])) {
|
||||
if ($first_appearance = $statements_analyzer->getFirstAppearance($var_id)) {
|
||||
$first_appearance = $statements_analyzer->getFirstAppearance($var_id);
|
||||
|
||||
$codebase = $statements_analyzer->getCodebase();
|
||||
|
||||
if ($first_appearance && $context->vars_in_scope[$var_id]->hasMixed()) {
|
||||
if (!$context->collect_initializations
|
||||
&& !$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',
|
||||
|
@ -1101,6 +1101,24 @@ class Analyzer
|
||||
++$this->mixed_counts[$file_path][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file_path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function decrementMixedCount($file_path)
|
||||
{
|
||||
if (!$this->count_mixed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($this->mixed_counts[$file_path])) {
|
||||
return;
|
||||
}
|
||||
|
||||
--$this->mixed_counts[$file_path][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file_path
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user