public function scan(FileIterator $fileIterator)
{
$this->dispatcher->dispatch(self::SCAN_START);
foreach ($fileIterator as $file) {
$this->dispatcher->dispatch(self::FILE_OPEN, new Event\FileEvent($file));
if ($file->isPathMatch('/\\.phps$/i')) {
$this->dispatcher->dispatch(self::FILE_ERROR, new Event\ErrorEvent('You have a .phps file - REMOVE NOW', $file));
}
try {
$this->visitor->setFile($file);
$this->traverser->traverse($this->parser->parse($file->getContents()));
} catch (\PhpParser\Error $e) {
$this->dispatcher->dispatch(self::FILE_ERROR, new Event\ErrorEvent($e->getMessage(), $file));
}
$this->dispatcher->dispatch(self::FILE_CLOSE);
}
$this->dispatcher->dispatch(self::SCAN_COMPLETE);
}