annotate vendor/squizlabs/php_codesniffer/src/Reports/Emacs.php @ 5:12f9dff5fda9 tip

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