Skip to content

Commit

Permalink
Remove some unnecessary ElseAnalyzer code
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 26, 2022
1 parent 8787e9d commit 45ba737
Showing 1 changed file with 14 additions and 17 deletions.
Expand Up @@ -117,11 +117,11 @@ public static function analyze(

/** @var array<string, int> */
$new_assigned_var_ids = $else_context->assigned_var_ids;
$else_context->assigned_var_ids = $pre_stmts_assigned_var_ids;
$else_context->assigned_var_ids += $pre_stmts_assigned_var_ids;

/** @var array<string, bool> */
$new_possibly_assigned_var_ids = $else_context->possibly_assigned_var_ids;
$else_context->possibly_assigned_var_ids = $pre_possibly_assigned_var_ids + $new_possibly_assigned_var_ids;
$else_context->possibly_assigned_var_ids += $pre_possibly_assigned_var_ids;

if ($else) {
foreach ($else_context->byref_constraints as $var_id => $byref_constraint) {
Expand Down Expand Up @@ -199,24 +199,21 @@ public static function analyze(

$possibly_assigned_var_ids = $new_possibly_assigned_var_ids;

if ($has_leaving_statements && $else_context->loop_scope) {
if (!$has_continue_statement && !$has_break_statement) {
$if_scope->new_vars_possibly_in_scope = array_merge(
$vars_possibly_in_scope,
$if_scope->new_vars_possibly_in_scope
);
if ($has_leaving_statements) {
if ($else_context->loop_scope) {
if (!$has_continue_statement && !$has_break_statement) {
$if_scope->new_vars_possibly_in_scope = array_merge(
$vars_possibly_in_scope,
$if_scope->new_vars_possibly_in_scope
);
}

$if_scope->possibly_assigned_var_ids = array_merge(
$possibly_assigned_var_ids,
$if_scope->possibly_assigned_var_ids
$else_context->loop_scope->vars_possibly_in_scope = array_merge(
$vars_possibly_in_scope,
$else_context->loop_scope->vars_possibly_in_scope
);
}

$else_context->loop_scope->vars_possibly_in_scope = array_merge(
$vars_possibly_in_scope,
$else_context->loop_scope->vars_possibly_in_scope
);
} elseif (!$has_leaving_statements) {
} else {
$if_scope->new_vars_possibly_in_scope = array_merge(
$vars_possibly_in_scope,
$if_scope->new_vars_possibly_in_scope
Expand Down

0 comments on commit 45ba737

Please sign in to comment.