/** * @return int[] */ private function getLinesVariableIsUsedOn() { $variables = $this->definedVars->all(); $variableName = $this->oldName->getName(); $lines = array(); if (isset($variables[$variableName])) { $lines = $variables[$variableName]; } return $lines; }
private function filterVariablesFromSelection($selectedVariables, DefinedVariables $selection, Closure $filter, $reducer) { $variablesUsed = array(); $compareLine = $reducer == 'max' ? $selection->endLine() : $selection->startLine(); $knownVariables = $this->all(); foreach ($selectedVariables as $variable) { if (!isset($knownVariables[$variable])) { continue; } $lastUsedLine = $reducer($knownVariables[$variable]); if ($filter($lastUsedLine, $compareLine)) { $variablesUsed[] = $variable; } } return $variablesUsed; }