/** * Test excludeMatchingPattern * * @return void */ public function testExcludeMatchingPattern() { $expected = array('/a/dir/source.php' => new File('/a/dir/source.php', array(new Issue('/a/dir/source.php', 37, 37, 'Checkstyle', 'm1', 'error')))); $this->sourceHandler->excludeMatchingPattern('*src.php'); $this->assertEquals($expected, $this->sourceHandler->getFiles()); }
/** * Main execute function for PHP_CodeBrowser. * * Following steps are resolved: * 1. Clean-up output directory * 2. Merge xml log files * 3. Generate XML file via error list from plugins * 4. Save the ErrorList as XML file * 5. Generate HTML output from XML * 6. Copy resources (css, js, images) from template directory to output * * @return void */ public function run() { // clear and create output directory if (is_dir($this->htmlOutputDir)) { $this->ioHelper->deleteDirectory($this->htmlOutputDir); } elseif (is_file($this->htmlOutputDir)) { $this->ioHelper->deleteFile($this->htmlOutputDir); } $this->ioHelper->createDirectory($this->htmlOutputDir); // init needed classes $viewReview = new ViewReview(PHPCB_TEMPLATE_DIR, $this->htmlOutputDir, $this->ioHelper, $this->phpSuffixes); $sourceHandler = new SourceHandler($this->debugLog); if (isset($this->logDir)) { $issueXml = new IssueXml(); // merge xml files $issueXml->addDirectory($this->logDir); // conversion of XML file cc to cb format foreach ($this->registeredPlugins as $className) { if (array_key_exists($className, $this->pluginOptions)) { $plugin = new $className($issueXml, $this->pluginOptions[$className]); } else { $plugin = new $className($issueXml); } $sourceHandler->addPlugin($plugin); } } if (isset($this->projectSource)) { foreach ($this->projectSource as $source) { if (is_dir($source)) { $factory = new File_Iterator_Factory(); $suffixes = array_merge($this->phpSuffixes, array('php', 'js', 'css', 'html')); $sourceHandler->addSourceFiles($factory->getFileIterator($source, $suffixes)); } else { $sourceHandler->addSourceFile($source); } } } array_walk($this->excludeExpressions, array($sourceHandler, 'excludeMatchingPCRE')); array_walk($this->excludePatterns, array($sourceHandler, 'excludeMatchingPattern')); $files = $sourceHandler->getFiles(); if (!$files) { $viewReview->copyNoErrorsIndex(); } else { // Get the path prefix all files have in common $commonPathPrefix = $sourceHandler->getCommonPathPrefix(); foreach ($files as $file) { $viewReview->generate($file->getIssues(), $file->name(), $commonPathPrefix, $this->excludeOK); } // Copy needed resources (eg js libraries) to output directory $viewReview->copyResourceFolders(); $viewReview->generateIndex($files, $this->excludeOK); } }