protected function analyzeFiles()
{
if (!$this->paths) {
$this->printHelp();
return;
}
$paths = array();
foreach ($this->paths as $path) {
if (!file_exists($path) || !is_readable($path)) {
echo "Cannot open " . $path . "\n";
}
if (is_dir($path)) {
$paths[] = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)), '(\\.php$)i');
} else {
$paths[] = $path;
}
}
$manager = new Manager(__DIR__ . '/../../../standards', '~/.flitch/standards', $this->standard);
$tokenizer = new Tokenizer();
if (false === $this->quiet) {
$this->reports['cli'] = new Report\Cli();
}
if (!empty($this->checkstyleReportFilename)) {
$this->reports['checkstyle'] = new Report\Checkstyle($this->checkstyleReportFilename);
}
foreach ($paths as $path) {
if (is_string($path)) {
$file = $this->analyzeFile($path, $tokenizer, $manager);
} else {
foreach ($path as $fileInfo) {
$file = $this->analyzeFile($fileInfo->getPathname(), $tokenizer, $manager);
}
}
}
}