Esempio n. 1
0
 protected function getParsedFile($file_id, $filename, $file_content)
 {
     if (!$this->pf || $this->pfFileId != $file_id) {
         // release the old file, if any
         if ($this->pf) {
             $this->pf->release();
             $this->pf = null;
         }
         try {
             $pf = $this->xref->getParsedFile($filename, $file_content);
             $this->pf = $pf;
             $this->pfFileId = $file_id;
             $this->parseException = null;
             $this->stats["parsed_files"]++;
         } catch (XRef_ParseException $e) {
             // catch XRef_ParseException here and allow to process the next file
             // however, all other exceptions are propagated
             $this->pf = false;
             $this->parseException = $e;
         }
     }
     return $this->pf;
 }
Esempio n. 2
0
 */
$includeDir = "@php_dir@" == "@" . "php_dir@" ? dirname(__FILE__) . "/.." : "@php_dir@/XRef";
require_once "{$includeDir}/XRef.class.php";
// web-server lint script
$xref = new XRef();
$xref->loadPluginGroup("lint");
$sourcePlugin = $xref->getPluginById("files");
$css = $sourcePlugin->getDefaultCSS();
$textareaContent = '// put source code here';
$report = null;
$exceptionMessage = null;
$formattedText = null;
if (isset($_REQUEST["source"]) && $_REQUEST["source"]) {
    $source = get_magic_quotes_gpc() ? stripslashes($_REQUEST["source"]) : $_REQUEST["source"];
    try {
        $parsed_file = $xref->getParsedFile("unknown.php", $source);
        if (count($parsed_file->getTokens()) > 1) {
            $lint_engine = XRef::getConfigValue("xref.project-check", true) ? new XRef_LintEngine_ProjectCheck($xref) : new XRef_LintEngine_Simple($xref);
            $lint_engine->addParsedFile($parsed_file);
            $report = $lint_engine->collectReport();
            $formattedText = $sourcePlugin->getFormattedText($parsed_file, "");
        } else {
            $textareaContent = htmlspecialchars($source);
        }
    } catch (Exception $e) {
        $exceptionMessage = $e->getMessage();
        $textareaContent = htmlspecialchars($source);
    }
}
echo $xref->fillTemplate('lint-web.tmpl', array('textareaContent' => $textareaContent, 'hasSource' => isset($source), 'formattedText' => $formattedText, 'exceptionMessage' => $exceptionMessage, 'report' => $report, 'css' => $css));
// vim: tabstop=4 expandtab
Esempio n. 3
0
$xref = new XRef();
$xref->setOutputDir(XRef::getConfigValue("doc.output-dir"));
$xref->loadPluginGroup("doc");
$plugins = $xref->getPlugins("XRef_IDocumentationPlugin");
$path = XRef::getConfigValue("project.source-code-dir");
$file_provider = new XRef_FileProvider_FileSystem($path);
$exclude_paths = XRef::getConfigValue("project.exclude-path", array());
$file_provider->excludePaths($exclude_paths);
$numberOfFiles = 0;
$numberOfCodeLines = 0;
// 1. Call each plugin once for each input file
$files = $xref->filterFiles($file_provider->getFiles());
foreach ($files as $filename) {
    try {
        $file_content = $file_provider->getFileContent($filename);
        $pf = $xref->getParsedFile($filename, $file_content);
        foreach ($plugins as $pluginId => $plugin) {
            $plugin->generateFileReport($pf);
        }
        $numberOfFiles++;
        $numberOfCodeLines += $pf->getNumberOfLines();
        $pf->release();
        // help PHP garbage collector to free memory
    } catch (Exception $e) {
        error_log("Can't process file '{$filename}': " . $e->getMessage() . "\n");
    }
}
// 2. Notify each plugin that all files are done
foreach ($plugins as $pluginId => $plugin) {
    $plugin->generateTotalReport();
}