annotate vendor/squizlabs/php_codesniffer/src/Reports/Emacs.php @ 19:fa3358dc1485 tip

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