Differential D13795 Diff 33335 src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | foreach ($defs as $def) { | ||||
continue; | continue; | ||||
} | } | ||||
if ($name !== 'extract') { | if ($name !== 'extract') { | ||||
continue; | continue; | ||||
} | } | ||||
$scope_destroyed_at = min($scope_destroyed_at, $call->getOffset()); | $scope_destroyed_at = min($scope_destroyed_at, $call->getOffset()); | ||||
} | } | ||||
$func_decls = $body->selectDescendantsOfType('n_FUNCTION_DECLARATION'); | |||||
foreach ($func_decls as $func_decl) { | |||||
if ($func_decl->getChildByIndex(2)->getTypeName() != 'n_EMPTY') { | |||||
continue; | |||||
} | |||||
foreach ($func_decl->selectDescendantsOfType('n_VARIABLE') as $var) { | |||||
$exclude_tokens[$var->getID()] = true; | |||||
} | |||||
} | |||||
// Now we have every declaration except foreach(), handled below. Build | // Now we have every declaration except foreach(), handled below. Build | ||||
// two maps, one which just keeps track of which tokens are part of | // two maps, one which just keeps track of which tokens are part of | ||||
// declarations ($declaration_tokens) and one which has the first offset | // declarations ($declaration_tokens) and one which has the first offset | ||||
// where a variable is declared ($declarations). | // where a variable is declared ($declarations). | ||||
foreach ($vars as $var) { | foreach ($vars as $var) { | ||||
$concrete = $this->getConcreteVariableString($var); | $concrete = $this->getConcreteVariableString($var); | ||||
$declarations[$concrete] = min( | $declarations[$concrete] = min( | ||||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |