Skip to content
Permalink
Browse files

Improve solution to #2546 slightly

  • Loading branch information
muglug committed Jan 3, 2020
1 parent 4263417 commit 0e39759ed63d747b9b78d7f12d68c66c96ba3c8d
@@ -494,10 +494,14 @@ public static function analyze(
}

foreach ($loop_scope->unreferenced_vars as $var_id => $locations) {
if (!isset($loop_scope->loop_context->unreferenced_vars[$var_id])) {
$loop_scope->loop_context->unreferenced_vars[$var_id] = $locations;
if (isset($loop_scope->referenced_var_ids[$var_id])) {
$statements_analyzer->registerVariableUses($locations);
} else {
$loop_scope->loop_context->unreferenced_vars[$var_id] += $locations;
if (!isset($loop_scope->loop_context->unreferenced_vars[$var_id])) {
$loop_scope->loop_context->unreferenced_vars[$var_id] = $locations;
} else {
$loop_scope->loop_context->unreferenced_vars[$var_id] += $locations;
}
}
}
}
@@ -441,11 +441,7 @@ function ($line) {
}
}

foreach ($loop_scope->unreferenced_vars as $var_id => $locations) {
if (!isset($context->unreferenced_vars[$var_id])) {
$this->registerVariableUses($locations);
}
}
$loop_scope->referenced_var_ids += $context->referenced_var_ids;
}
}

@@ -545,11 +541,7 @@ function ($line) {
}
}

foreach ($loop_scope->unreferenced_vars as $var_id => $locations) {
if (!isset($context->unreferenced_vars[$var_id])) {
$this->registerVariableUses($locations);
}
}
$loop_scope->referenced_var_ids += $context->referenced_var_ids;
}
}

@@ -60,6 +60,11 @@ class LoopScope
*/
public $unreferenced_vars = [];

/**
* @var array<string, bool>
*/
public $referenced_var_ids = [];

/**
* @var array<string, array<string, CodeLocation>>
*/

0 comments on commit 0e39759

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