本文整理汇总了PHP中PHP_CodeSniffer::prepareErrorReport方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer::prepareErrorReport方法的具体用法?PHP PHP_CodeSniffer::prepareErrorReport怎么用?PHP PHP_CodeSniffer::prepareErrorReport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeSniffer
的用法示例。
在下文中一共展示了PHP_CodeSniffer::prepareErrorReport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputCustomFormat
/**
* Outputs the results with a custom format
* @param PHP_CodeSniffer $codeSniffer
*/
protected function outputCustomFormat($codeSniffer)
{
$report = $codeSniffer->prepareErrorReport($this->showWarnings);
$files = $report['files'];
foreach ($files as $file => $attributes) {
$errors = $attributes['errors'];
$warnings = $attributes['warnings'];
$messages = $attributes['messages'];
if ($errors > 0) {
$this->log($file . ': ' . $errors . ' error' . ($errors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
$this->outputCustomFormatMessages($messages, 'ERROR');
} else {
$this->log($file . ': No syntax errors detected', Project::MSG_VERBOSE);
}
if ($warnings > 0) {
$this->log($file . ': ' . $warnings . ' warning' . ($warnings > 1 ? 's' : '') . ' detected', Project::MSG_WARN);
$this->outputCustomFormatMessages($messages, 'WARNING');
}
}
$totalErrors = $report['totals']['errors'];
$totalWarnings = $report['totals']['warnings'];
$this->log(count($files) . ' files where checked', Project::MSG_INFO);
if ($totalErrors > 0) {
$this->log($totalErrors . ' error' . ($totalErrors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
} else {
$this->log('No syntax errors detected', Project::MSG_INFO);
}
if ($totalWarnings > 0) {
$this->log($totalWarnings . ' warning' . ($totalWarnings > 1 ? 's' : '') . ' detected', Project::MSG_INFO);
}
}
示例2: _runPHPCSWithClass
protected function _runPHPCSWithClass($file)
{
// Check the PHP version.
if (version_compare(PHP_VERSION, '5.1.0') === -1) {
echo 'ERROR: PEAR_Enforce requires PHP version 5.1.0 or greater.' . "\n";
exit(2);
}
require_once 'PHP/CodeSniffer.php';
$phpcs = new PHP_CodeSniffer(0, 4);
$phpcs->process($file, "PEAR", array(), false);
$results = $phpcs->prepareErrorReport(true);
$results = $results['files'][$file]['messages'];
return $results;
}