Skip to content
Permalink
Browse files

Fix issue where inside_conditional is forgotten

  • Loading branch information
muglug committed Dec 11, 2019
1 parent 2f9b1ff commit e476eed1110b8b21d9940ddbe8d466aa35c88054
@@ -564,6 +564,8 @@ function (Clause $c) use ($changed_var_ids) {

$internally_applied_if_cond_expr = self::getDefinitelyEvaluatedExpressionInsideIf($cond);

$was_inside_conditional = $outer_context->inside_conditional;

$outer_context->inside_conditional = true;

$pre_condition_vars_in_scope = $outer_context->vars_in_scope;
@@ -602,7 +604,9 @@ function (Clause $c) use ($changed_var_ids) {
$first_cond_referenced_var_ids
);

$outer_context->inside_conditional = false;
if (!$was_inside_conditional) {
$outer_context->inside_conditional = false;
}

if (!$if_context) {
$if_context = clone $outer_context;
@@ -267,6 +267,7 @@ private static function handleCase(
$old_node_data = $statements_analyzer->node_data;

if ($case->cond) {
$was_inside_conditional = $case_context->inside_conditional;
$case_context->inside_conditional = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $case->cond, $case_context) === false) {
@@ -278,7 +279,9 @@ private static function handleCase(
return false;
}

$case_context->inside_conditional = false;
if (!$was_inside_conditional) {
$case_context->inside_conditional = false;
}

$statements_analyzer->node_data = clone $statements_analyzer->node_data;

@@ -642,6 +642,21 @@ function takesMixed($i) : int {
return $i;
}'
],
'usedFunctionCallInsideSwitchWithTernary' => [
'<?php
function getArg(string $method) : void {
switch (strtolower($method ?: "")) {
case "post":
break;
case "get":
break;
default:
break;
}
}'
]
];
}

0 comments on commit e476eed

Please sign in to comment.
You can’t perform that action at this time.