Exemplo n.º 1
0
 /**
  * Main execute function for PHP_CodeBrowser.
  *
  * Following steps are resolved:
  * 1. Clean-up output directory
  * 2. Merge xml log files
  * 3. Generate cbXML file via errorlist from plugins
  * 4. Save the cbErrorList as XML file
  * 5. Generate HTML output from cbXML
  * 6. Copy ressources (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);
     } else {
         if (is_file($this->_htmlOutputDir)) {
             $this->_ioHelper->deleteFile($this->_htmlOutputDir);
         }
     }
     $this->_ioHelper->createDirectory($this->_htmlOutputDir);
     // init needed classes
     $cbViewReview = new CbViewReview(PHPCB_TEMPLATE_DIR, $this->_htmlOutputDir, $this->_ioHelper, $this->_phpSuffixes);
     $sourceHandler = new CbSourceHandler($this->_debugLog);
     if (isset($this->_logDir)) {
         $cbIssueXml = new CbIssueXml();
         // merge xml files
         $cbIssueXml->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($cbIssueXml, $this->_pluginOptions[$className]);
             } else {
                 $plugin = new $className($cbIssueXml);
             }
             $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) {
         $cbViewReview->copyNoErrorsIndex();
     } else {
         // Get the path prefix all files have in common
         $commonPathPrefix = $sourceHandler->getCommonPathPrefix();
         $error_reporting = ini_get('error_reporting');
         // Disable E_Strict, Text_Highlighter might throw up
         ini_set('error_reporting', $error_reporting & ~E_STRICT);
         foreach ($files as $file) {
             $cbViewReview->generate($file->getIssues(), $file->name(), $commonPathPrefix, $this->_excludeOK);
         }
         ini_set('error_reporting', $error_reporting);
         // Copy needed ressources (eg js libraries) to output directory
         $cbViewReview->copyRessourceFolders();
         $cbViewReview->generateIndex($files, $this->_excludeOK);
     }
 }
    /**
    
        /**
    * 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 CbIssueXml();
        foreach ($xmlStrings as $xmlString) {
            $xml = new DOMDocument('1.0', 'UTF-8');
            $xml->validateOnParse = true;
            $xml->loadXML($xmlString);
            $issueXML->addXMLFile($xml);
        }
        $this->_plugins = array(new CbErrorCheckstyle($issueXML), new CbErrorPMD($issueXML));
    }
Exemplo n.º 3
0
 /**
  * Main execute function for PHP_CodeBrowser.
  *
  * Following steps are resolved:
  * 1. Clean-up output directory
  * 2. Merge xml log files
  * 3. Generate cbXML file via errorlist from plugins
  * 4. Save the cbErrorList as XML file
  * 5. Generate HTML output from cbXML
  * 6. Copy ressources (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);
     } else {
         if (is_file($this->_htmlOutputDir)) {
             $this->_ioHelper->deleteFile($this->_htmlOutputDir);
         }
     }
     $this->_ioHelper->createDirectory($this->_htmlOutputDir);
     // init needed classes
     $cbViewReview = new CbViewReview(PHPCB_TEMPLATE_DIR, $this->_htmlOutputDir, $this->_ioHelper);
     $sourceHandler = new CbSourceHandler();
     if (isset($this->_logDir)) {
         $cbIssueXml = new CbIssueXml();
         // merge xml files
         $cbIssueXml->addDirectory($this->_logDir);
         // conversion of XML file cc to cb format
         foreach ($this->_registeredPlugins as $className) {
             $sourceHandler->addPlugin(new $className($cbIssueXml));
         }
     }
     if (isset($this->_projectSource)) {
         foreach ($this->_projectSource as $source) {
             if (is_dir($source)) {
                 $sourceHandler->addSourceFiles(File_Iterator_Factory::getFileIterator($source, array('php', 'js', 'css', 'html')));
             } else {
                 $sourceHandler->addSourceFile($source);
             }
         }
     }
     array_walk($this->_excludeExpressions, array($sourceHandler, 'excludeMatchingPCRE'));
     array_walk($this->_excludePatterns, array($sourceHandler, 'excludeMatchingPattern'));
     $files = $sourceHandler->getFiles();
     if (!$files) {
         $cbViewReview->copyNoErrorsIndex();
     } else {
         // Get the path prefix all files have in common
         $commonPathPrefix = $sourceHandler->getCommonPathPrefix();
         foreach ($files as $file) {
             $cbViewReview->generate($file->getIssues(), $file->name(), $commonPathPrefix);
         }
         // Copy needed ressources (eg js libraries) to output directory
         $cbViewReview->copyRessourceFolders();
         $cbViewReview->generateIndex($files);
     }
 }
Exemplo n.º 4
0
 /**
  * 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));
 }