define("PHPCHECKSTYLE_HOME_DIR", dirname(__FILE__)); require_once "vendor/autoload.php"; // default values $options['format'] = "array"; // default format // Get user selection $sourceDir = $_POST['sourceDir']; $resultDir = $_POST['resultDir']; $configFile = $_POST['configFile']; $lange = $_POST['lang']; if ($_POST['excludeFile']) { $expFile = explode(',', $_POST['excludeFile']); $options['exclude'] = $expFile; } else { $options['exclude'] = array(); } // $formats = explode(',', $options['format']); $sources = explode(',', $sourceDir); // TODO: Make this an includeable file $configFile = array('indentation' => array("type" => "spaces", "number" => 2)); // Launch PHPCheckstyle $style = new PHPCheckstyle\PHPCheckstyle($formats, $resultDir, $configFile, null, false, true); if (file_exists(__DIR__ . '/src/PHPCheckstyle/Lang/' . $options['lang'] . '.ini')) { $style->setLang($options['lang']); } $style->processFiles($sources, $options['exclude']); echo "<pre>" . print_r($style->_reporter->reporters[0]->outputFile, TRUE) . "</pre>"; echo "Reporting Completed.</BR></BR>"; echo 'Display Results : <a href="' . $resultDir . '">' . $resultDir . '</a>';
} define("PHPCHECKSTYLE_HOME_DIR", dirname(__FILE__)); // require_once PHPCHECKSTYLE_HOME_DIR."/src/PHPCheckstyle.php"; require_once "vendor/autoload.php"; // check for valid format and set the output file name // right now the output file name is not configurable, only // the output directory is configurable (from command line) $knownFormats = array('html', 'html_console', 'console', 'text', 'xml', 'xml_console', 'array'); $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']); if (!$options['quiet']) { echo "\nReporting Completed.\n"; } exit(0);
$knownFormats = array('html', 'html_console', 'console', 'text', 'xml', 'xml_console', 'array'); $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; }