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

Simplify a bit of logic in switch analysis

This commit is contained in:
Matthew Brown 2021-05-13 17:31:17 -04:00
parent 18931295c4
commit bb8ce8817d

View File

@ -203,7 +203,11 @@ class SwitchCaseAnalyzer
}
}
if (($switch_condition_type = $statements_analyzer->node_data->getType($switch_condition))
if ($switch_condition instanceof PhpParser\Node\Expr\ConstFetch
&& $switch_condition->name->parts === ['true']
) {
$case_equality_expr = $case->cond;
} elseif (($switch_condition_type = $statements_analyzer->node_data->getType($switch_condition))
&& ($case_cond_type = $statements_analyzer->node_data->getType($case->cond))
&& (($switch_condition_type->isString() && $case_cond_type->isString())
|| ($switch_condition_type->isInt() && $case_cond_type->isInt())