Skip to content

Commit

Permalink
Simplify a bit of logic in switch analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 13, 2021
1 parent 1893129 commit bb8ce88
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ public static function analyze(
}
}

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())
Expand Down

0 comments on commit bb8ce88

Please sign in to comment.