Skip to content

Commit

Permalink
always unflag before leaving a analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Dec 21, 2021
1 parent b1a1c65 commit ca25b0f
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public static function analyze(
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}
$context->inside_general_use = $was_inside_general_use;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ private static function analyzeArrayItem(
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $item->key, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return;
}
$context->inside_general_use = $was_inside_general_use;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@ private static function analyzeNestedArrayAssignment(
$child_stmt->dim,
$context
) === false) {
$context->inside_general_use = $was_inside_general_use;

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public static function analyze(
$context->inside_general_use = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $prop_name, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public static function analyze(
}

if (ExpressionAnalyzer::analyze($statements_analyzer, $assign_value, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

if ($var_id) {
if ($array_var_id) {
$context->removeDescendents($array_var_id, null, $assign_value_type);
Expand Down Expand Up @@ -1501,10 +1503,14 @@ private static function analyzePropertyAssignment(
// this can happen when the user actually means to type $this-><autocompleted>, but there's
// a variable on the next line
if (ExpressionAnalyzer::analyze($statements_analyzer, $assign_var->var, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return;
}

if (ExpressionAnalyzer::analyze($statements_analyzer, $assign_var->name, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return;
}

Expand Down Expand Up @@ -1693,6 +1699,8 @@ private static function analyzeAssignmentToVariable(
$context->inside_general_use = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $assign_var->name, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ public static function analyze(
$context->inside_call = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $arg->value, $context) === false) {
$context->inside_call = $was_inside_call;

return false;
}

Expand Down Expand Up @@ -1116,6 +1118,8 @@ private static function evaluateArbitraryParam(
$context->inside_call = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $arg->value, $context) === false) {
$context->inside_call = $was_inside_call;

return false;
}

Expand Down Expand Up @@ -1225,6 +1229,8 @@ private static function handleByRefFunctionArg(
$arg->value,
$context
) === false) {
$context->inside_assignment = $was_inside_assignment;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ function ($arg) {
$args[$i]->value,
$context
) === false) {
$context->inside_assignment = $was_inside_assignment;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static function analyze(
if ($existing_stmt_var_type) {
$statements_analyzer->node_data->setType($stmt->var, $existing_stmt_var_type);
} elseif (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->var, $context) === false) {
$context->inside_call = $was_inside_call;

return false;
}

Expand All @@ -70,6 +72,8 @@ public static function analyze(
$context->inside_call = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->name, $context) === false) {
$context->inside_call = $was_inside_call;

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public static function analyze(
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}
$context->inside_general_use = $was_inside_general_use;
Expand All @@ -208,6 +210,8 @@ public static function analyze(
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}
$context->inside_general_use = $was_inside_general_use;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public static function analyze(
$context->inside_unset = false;

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->dim, $context) === false) {
$context->inside_unset = $was_inside_unset;
$context->inside_general_use = $was_inside_general_use;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ public static function analyze(
$context->inside_general_use = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->class, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static function analyze(
}

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->var, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static function analyze(
$context->inside_call = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) {
$context->inside_call = $was_inside_call;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public static function analyze(
$context->inside_general_use = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) {
$context->inside_general_use = $was_inside_general_use;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static function analyze(
$always_non_empty_array
) === false
) {
$context->inside_call = $was_inside_call;

return false;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ private static function handleExpression(
$was_inside_call = $context->inside_call;
$context->inside_call = true;
if (PrintAnalyzer::analyze($statements_analyzer, $stmt, $context) === false) {
$context->inside_call = $was_inside_call;

return false;
}
$context->inside_call = $was_inside_call;
Expand Down

0 comments on commit ca25b0f

Please sign in to comment.