Mercurial > hg > cmmr2012-drupal-site
comparison vendor/squizlabs/php_codesniffer/src/Reports/Emacs.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
1 <?php | |
2 /** | |
3 * Emacs 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 Emacs 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 $message = $error['message']; | |
43 if ($showSources === true) { | |
44 $message .= ' ('.$error['source'].')'; | |
45 } | |
46 | |
47 $type = strtolower($error['type']); | |
48 echo $report['filename'].':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL; | |
49 } | |
50 } | |
51 } | |
52 | |
53 return true; | |
54 | |
55 }//end generateFileReport() | |
56 | |
57 | |
58 /** | |
59 * Generates an emacs 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 $cachedData; | |
86 | |
87 }//end generate() | |
88 | |
89 | |
90 }//end class |