function Csv::generateFileReport
Generate a partial report for a single processed file.
Function should return TRUE if it printed or stored data about the file and FALSE if it ignored the file. Returning TRUE indicates that the file and its data should be counted in the grand totals.
Parameters
array<string, string|int|array> $report Prepared report data.: See the {@see Report} interface for a detailed specification.
\PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.:
bool $showSources Show sources?:
int $width Maximum allowed line width.:
Return value
bool
Overrides Report::generateFileReport
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Reports/ Csv.php, line 33
Class
Namespace
PHP_CodeSniffer\ReportsCode
public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80) {
if ($report['errors'] === 0 && $report['warnings'] === 0) {
// Nothing to print.
return false;
}
foreach ($report['messages'] as $line => $lineErrors) {
foreach ($lineErrors as $column => $colErrors) {
foreach ($colErrors as $error) {
$filename = str_replace('"', '\\"', $report['filename']);
$message = str_replace('"', '\\"', $error['message']);
$type = strtolower($error['type']);
$source = $error['source'];
$severity = $error['severity'];
$fixable = (int) $error['fixable'];
echo "\"{$filename}\",{$line},{$column},{$type},\"{$message}\",{$source},{$severity},{$fixable}" . PHP_EOL;
}
}
}
return true;
}