private function run()
{
$issues = [];
$totalFiles = 0;
$totalLines = 0;
$filePath = $this->scanner->getCurrentFilePath();
if (!$this->options->getOption('t') || in_array('syntax', $this->options->getOption('t'), true)) {
$checkSyntax = true;
$versionGood = $this->tests->getPHPVersion();
if (!$versionGood) {
$this->reporter->add("ERROR! Syntax checking was selected and a PHP binary lower than 7.0.0-dev was specified.", 0, 1);
}
} else {
$checkSyntax = false;
}
while (($lines = $this->scanner->scanNextFile()) !== false) {
$totalFiles++;
//Check syntax and assign a line to grab if needed.
$grabLineNumber = null;
$grabLine = null;
if ($checkSyntax) {
$syntax = $this->tests->checkSyntax($filePath);
if (!isset($syntax['is_valid'])) {
$grabLineNumber = $syntax['line'];
}
}
foreach ($lines as $index => $line) {
$lineNumber = $index + 1;
$line = trim($line, "\r\n");
if ($lineNumber == $grabLineNumber) {
$grabLine = $line;
}
$totalLines++;
$issues = $this->tests->testLine($line);
foreach ($issues as $section => $tests) {
foreach ($tests as $test => $true) {
$this->reporter->addToSection($section, $test, $filePath, $lineNumber, $line);
}
}
}
if ($checkSyntax && $grabLine !== null) {
$this->reporter->addToSection('syntax', 'syntax', $filePath, $grabLineNumber, $grabLine . ' //' . $syntax['error']);
}
$filePath = $this->scanner->getCurrentFilePath();
}
$this->reporter->add("Processed {$totalLines} lines contained in {$totalFiles} files.", 0, 1);
}