示例#1
0
$formats = explode(',', $options['format']);
$unknownFormats = array_diff($formats, $knownFormats);
if (!empty($unknownFormats)) {
    echo sprintf("\nUnknown format %s.\n\n", implode(', ', $unknownFormats));
    usage();
}
// check that source directory is specified and is valid
if (!$options['src']) {
    echo "\nPlease specify a source directory/file using --src option.\n\n";
    usage();
}
if (!empty($options['linecount'])) {
    $lineCountFile = "ncss.xml";
}
$style = new PHPCheckstyle\PHPCheckstyle($formats, $options['outdir'], $options['config'], $lineCountFile, $options['debug'], $options['progress']);
if (file_exists(__DIR__ . '/src/PHPCheckstyle/Lang/' . $options['lang'] . '.ini')) {
    $style->setLang($options['lang']);
}
$style->processFiles($options['src'], $options['exclude']);
$errorCounts = $style->getErrorCounts();
if (!$options['quiet']) {
    echo PHP_EOL . "Summary" . PHP_EOL;
    echo "=======" . PHP_EOL . PHP_EOL;
    echo "Errors:   " . $errorCounts[ERROR] . PHP_EOL;
    echo "Ignores:  " . $errorCounts[IGNORE] . PHP_EOL;
    echo "Infos:    " . $errorCounts[INFO] . PHP_EOL;
    echo "Warnings: " . $errorCounts[WARNING] . PHP_EOL;
    echo "=======" . PHP_EOL . PHP_EOL;
    echo "Reporting Completed." . PHP_EOL;
}
exit(0);