Esempio n. 1
0
 public function __construct(XRef $xref, $use_cache = true)
 {
     $this->xref = $xref;
     // do we have a storage manager?
     if ($use_cache) {
         try {
             $this->storageManager = $xref->getStorageManager();
         } catch (Exception $e) {
             // NOP
         }
     }
     // error map (error code => error description)
     // TODO: make it static
     $this->plugins = $xref->getPlugins("XRef_ILintPlugin");
     $this->fillErrorMap($this->plugins);
     $this->stats = array('total_files' => 0, 'parsed_files' => 0, 'cache_hit' => 0);
 }
Esempio n. 2
0
try {
    list($options, $arguments) = XRef::getCmdOptions();
} catch (Exception $e) {
    error_log($e->getMessage());
    error_log("See 'xref-doc --help'");
    exit(1);
}
//help
if (XRef::needHelp() || count($arguments)) {
    XRef::showHelpScreen("xref-doc - tool to create cross-reference source code reports");
    exit(1);
}
$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);
        }
Esempio n. 3
0
$f = function () use($serialized) {
    $stmts = unserialize($serialized);
};
my_echo("PHP-P array unserialize time", $b->timeIt($f), "sec");
$xref = new XRef();
// init autoload etc
$parser = new XRef_Parser_PHP();
$f = function () use($parser, $code, $filename) {
    $pf = $parser->parse($code, $filename);
    $pf->release();
};
my_echo("XRef internal parser", $b->timeIt($f, 30), "sec");
$slices = array();
$pf = $parser->parse($code, $filename);
$project_database = new XRef_ProjectDatabase();
foreach ($xref->getPlugins("XRef_IProjectLintPlugin") as $id => $plugin) {
    $slices[$id] = $plugin->createFileSlice($pf);
}
$slices['_db'] = $project_database->createFileSlice($pf);
$pf->release();
$serialized = serialize($slices);
my_echo("XRef serialized size", strlen($serialized), "bytes");
$compressed = gzcompress($serialized);
my_echo("XRef compressed size", strlen($compressed), "bytes");
$f = function () use($serialized) {
    $slices = unserialize($serialized);
};
my_echo("XRef unserialize time", $b->timeIt($f), "sec");
function my_echo($prefix, $data, $suffix = null)
{
    printf('%-30s %s', $prefix . ':', $data);
Esempio n. 4
0
 protected static function showErrors()
 {
     // map: error code => array("message" => message, "severity" => severity)
     $errors = array(XRef::ERROR_CODE_CANT_PARSE_FILE => array("message" => XRef::ERROR_MESSAGE_CANT_PARSE_FILE, "severity" => XRef::FATAL));
     $xref = new XRef();
     $xref->loadPluginGroup('lint');
     foreach ($xref->getPlugins('XRef_ILintPlugin') as $plugin) {
         $map = $plugin->getErrorMap();
         $errors = array_merge($errors, $map);
     }
     foreach ($xref->getPlugins('XRef_IProjectLintPlugin') as $plugin) {
         $map = $plugin->getErrorMap();
         $errors = array_merge($errors, $map);
     }
     ksort($errors);
     $format = "%-6s %-10s %s\n";
     $spacer = sprintf($format, str_repeat('-', 6), str_repeat('-', 10), str_repeat('-', 50));
     printf($format, "Code", "Severity", "Message");
     echo $spacer;
     foreach ($errors as $code => $details) {
         printf($format, $code, XRef::$severityNames[$details["severity"]], $details["message"]);
     }
     echo $spacer;
 }