/**
  * Get all DOMNodes that represent issues for a specific file.
  *
  * @param string $filename      Name of the file to get nodes for.
  *
  * @return DOMNodeList
  */
 protected function getIssueNodes($filename)
 {
     return $this->issueXml->query(sprintf('/*/%s/file[@name="%s"]', $this->pluginName, $filename));
 }
    /**
     * Initializes common values.
     */
    public function __construct()
    {
        $xmlStrings = array(<<<HERE
<?xml version="1.0" encoding="UTF-8"?>
<pmd version="0.2.6" timestamp="2010-08-12T00:00:00+02:000">
    <file name='/a/nother/dir/src.php'>
        <violation beginline="291" endline="291" rule="ExitExpression"
            ruleset="Design Rules"
            externalInfoUrl="http://example.com" priority="1">descr</violation>
    </file>
</pmd>
HERE
, <<<HERE
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.2.0RC3">
    <file name="/a/dir/source.php">
        <error line="37" column="1" severity="error"
            message="m1" source="PEAR.Commenting.FileCommentSniff"/>
    </file>
    <file name="/a/nother/dir/src.php">
        <error line="39" column="1" severity="error"
            message="m3" source="PEAR.Commenting.FileCommentSniff"/>
        <error line="40" column="1" severity="error"
            message="m4" source="PEAR.Commenting.FileCommentSniff"/>
    </file>
</checkstyle>
HERE
);
        $issueXML = new IssueXml();
        foreach ($xmlStrings as $xmlString) {
            $xml = new \DOMDocument('1.0', 'UTF-8');
            $xml->validateOnParse = true;
            $xml->loadXML($xmlString);
            $issueXML->addXMLFile($xml);
        }
        $this->plugins = array(new ErrorCheckstyle($issueXML), new ErrorPMD($issueXML));
    }
 /**
  * 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);
     }
 }