public function printErrorReport(PHP_CodeSniffer $phpcs, $reports, $showSources, $reportFile, $reportWidth)
{
if (empty($reports) === true) {
$reports['full'] = $reportFile;
}
$errors = 0;
$warnings = 0;
$toScreen = false;
foreach ($reports as $report => $output) {
if ($output === null) {
$output = $reportFile;
}
if ($reportFile === null) {
$toScreen = true;
}
// We don't add errors here because the number of
// errors reported by each report type will always be the
// same, so we really just need 1 number.
$result = $phpcs->reporting->printReport($report, $showSources, $this->values, $output, $reportWidth);
$errors = $result['errors'];
$warnings = $result['warnings'];
}
//end foreach
// Only print timer output if no reports were
// printed to the screen so we don't put additional output
// in something like an XML report. If we are printing to screen,
// the report types would have already worked out who should
// print the timer info.
if (PHP_CODESNIFFER_INTERACTIVE === false && ($toScreen === false || $errors + $warnings === 0 && $this->values['showProgress'] === true)) {
PHP_CodeSniffer_Reporting::printRunTime();
}
// They should all return the same value, so it
// doesn't matter which return value we end up using.
$ignoreWarnings = PHP_CodeSniffer::getConfigData('ignore_warnings_on_exit');
$ignoreErrors = PHP_CodeSniffer::getConfigData('ignore_errors_on_exit');
$return = $errors + $warnings;
if ($ignoreErrors !== null) {
$ignoreErrors = (bool) $ignoreErrors;
if ($ignoreErrors === true) {
$return -= $errors;
}
}
if ($ignoreWarnings !== null) {
$ignoreWarnings = (bool) $ignoreWarnings;
if ($ignoreWarnings === true) {
$return -= $warnings;
}
}
return $return;
}