Mercurial > hg > isophonics-drupal-site
comparison vendor/squizlabs/php_codesniffer/src/Reports/Csv.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 /** | |
3 * CSV report for PHP_CodeSniffer. | |
4 * | |
5 * @author Greg Sherwood <gsherwood@squiz.net> | |
6 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) | |
7 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | |
8 */ | |
9 | |
10 namespace PHP_CodeSniffer\Reports; | |
11 | |
12 use PHP_CodeSniffer\Files\File; | |
13 | |
14 class Csv implements Report | |
15 { | |
16 | |
17 | |
18 /** | |
19 * Generate a partial report for a single processed file. | |
20 * | |
21 * Function should return TRUE if it printed or stored data about the file | |
22 * and FALSE if it ignored the file. Returning TRUE indicates that the file and | |
23 * its data should be counted in the grand totals. | |
24 * | |
25 * @param array $report Prepared report data. | |
26 * @param \PHP_CodeSniffer\File $phpcsFile The file being reported on. | |
27 * @param bool $showSources Show sources? | |
28 * @param int $width Maximum allowed line width. | |
29 * | |
30 * @return bool | |
31 */ | |
32 public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) | |
33 { | |
34 if ($report['errors'] === 0 && $report['warnings'] === 0) { | |
35 // Nothing to print. | |
36 return false; | |
37 } | |
38 | |
39 foreach ($report['messages'] as $line => $lineErrors) { | |
40 foreach ($lineErrors as $column => $colErrors) { | |
41 foreach ($colErrors as $error) { | |
42 $filename = str_replace('"', '\"', $report['filename']); | |
43 $message = str_replace('"', '\"', $error['message']); | |
44 $type = strtolower($error['type']); | |
45 $source = $error['source']; | |
46 $severity = $error['severity']; | |
47 $fixable = (int) $error['fixable']; | |
48 echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity,$fixable".PHP_EOL; | |
49 } | |
50 } | |
51 } | |
52 | |
53 return true; | |
54 | |
55 }//end generateFileReport() | |
56 | |
57 | |
58 /** | |
59 * Generates a csv report. | |
60 * | |
61 * @param string $cachedData Any partial report data that was returned from | |
62 * generateFileReport during the run. | |
63 * @param int $totalFiles Total number of files processed during the run. | |
64 * @param int $totalErrors Total number of errors found during the run. | |
65 * @param int $totalWarnings Total number of warnings found during the run. | |
66 * @param int $totalFixable Total number of problems that can be fixed. | |
67 * @param bool $showSources Show sources? | |
68 * @param int $width Maximum allowed line width. | |
69 * @param bool $interactive Are we running in interactive mode? | |
70 * @param bool $toScreen Is the report being printed to screen? | |
71 * | |
72 * @return void | |
73 */ | |
74 public function generate( | |
75 $cachedData, | |
76 $totalFiles, | |
77 $totalErrors, | |
78 $totalWarnings, | |
79 $totalFixable, | |
80 $showSources=false, | |
81 $width=80, | |
82 $interactive=false, | |
83 $toScreen=true | |
84 ) { | |
85 echo 'File,Line,Column,Type,Message,Source,Severity,Fixable'.PHP_EOL; | |
86 echo $cachedData; | |
87 | |
88 }//end generate() | |
89 | |
90 | |
91 }//end class |