function testExpand($input, $expected) { global $quiet; $desc = "Expansion of \"{$input}\" - "; if (!$quiet) { echo $desc; } if (tab_expand($input) != $expected) { if ($quiet) { echo $desc; } echo "FAILED\n"; return false; } else { if (!$quiet) { echo "SUCCESS\n"; } } $desc = "Collapse of \"{$expected}\" - "; if (!$quiet) { echo $desc; } if (tab_collapse($expected, 8) != $input) { if ($quiet) { echo $desc; } echo "FAILED\n"; return false; } else { if (!$quiet) { echo "SUCCESS\n"; } } return true; }
protected function lintSpaceAlignment($path) { $lines = explode("\n", $this->getData($path)); $change = false; foreach ($lines as $line_idx => $line) { $expanded = tab_expand($line); $changedline = tab_collapse($expanded, 8); if (strcmp($line, $changedline)) { $this->raiseLintAtLine($line_idx + 1, 1, self::LINT_SPACE_ALIGNMENT, 'This line uses spaces in stead of tabs', $line, $changedline); $change = true; } } if ($change) { $this->nrautofixes++; } }