mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
fix wrong handling of flags in context
This commit is contained in:
parent
98f80446a3
commit
56369a7ba6
@ -163,13 +163,15 @@ class IfConditionalAnalyzer
|
||||
$referenced_var_ids = $first_cond_referenced_var_ids;
|
||||
$if_conditional_context->referenced_var_ids = [];
|
||||
|
||||
$was_inside_conditional = $if_conditional_context->inside_conditional;
|
||||
|
||||
$if_conditional_context->inside_conditional = true;
|
||||
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $cond, $if_conditional_context) === false) {
|
||||
throw new ScopeAnalysisException();
|
||||
}
|
||||
|
||||
$if_conditional_context->inside_conditional = false;
|
||||
$if_conditional_context->inside_conditional = $was_inside_conditional;
|
||||
|
||||
/** @var array<string, bool> */
|
||||
$more_cond_referenced_var_ids = $if_conditional_context->referenced_var_ids;
|
||||
|
@ -622,6 +622,8 @@ class LoopAnalyzer
|
||||
$pre_referenced_var_ids = $loop_context->referenced_var_ids;
|
||||
$loop_context->referenced_var_ids = [];
|
||||
|
||||
$was_inside_conditional = $loop_context->inside_conditional;
|
||||
|
||||
$loop_context->inside_conditional = true;
|
||||
|
||||
$suppressed_issues = $statements_analyzer->getSuppressedIssues();
|
||||
@ -637,10 +639,12 @@ class LoopAnalyzer
|
||||
}
|
||||
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $pre_condition, $loop_context) === false) {
|
||||
$loop_context->inside_conditional = $was_inside_conditional;
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
$loop_context->inside_conditional = false;
|
||||
$loop_context->inside_conditional = $was_inside_conditional;
|
||||
|
||||
$new_referenced_var_ids = $loop_context->referenced_var_ids;
|
||||
$loop_context->referenced_var_ids = array_merge($pre_referenced_var_ids, $new_referenced_var_ids);
|
||||
|
@ -31,12 +31,17 @@ class SwitchAnalyzer
|
||||
): void {
|
||||
$codebase = $statements_analyzer->getCodebase();
|
||||
|
||||
$was_inside_conditional = $context->inside_conditional;
|
||||
|
||||
$context->inside_conditional = true;
|
||||
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->cond, $context) === false) {
|
||||
$context->inside_conditional = $was_inside_conditional;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$context->inside_conditional = false;
|
||||
$context->inside_conditional = $was_inside_conditional;
|
||||
|
||||
$switch_var_id = ExpressionIdentifier::getArrayVarId(
|
||||
$stmt->cond,
|
||||
|
Loading…
Reference in New Issue
Block a user