• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 13840728520

13 Mar 2025 05:19PM UTC coverage: 78.682%. Remained the same
13840728520

Pull #870

github

web-flow
Merge c07267e91 into f91c0445f
Pull Request #870: Tests/Tokenizer: fix `conditions` checking range in `T_DEFAULT` test

24829 of 31556 relevant lines covered (78.68%)

66.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Reports/Csv.php
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/PHPCSStandards/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<string, string|int|array> $report      Prepared report data.
26
     *                                                     See the {@see Report} interface for a detailed specification.
27
     * @param \PHP_CodeSniffer\Files\File     $phpcsFile   The file being reported on.
28
     * @param bool                            $showSources Show sources?
29
     * @param int                             $width       Maximum allowed line width.
30
     *
31
     * @return bool
32
     */
33
    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
×
34
    {
35
        if ($report['errors'] === 0 && $report['warnings'] === 0) {
×
36
            // Nothing to print.
37
            return false;
×
38
        }
39

40
        foreach ($report['messages'] as $line => $lineErrors) {
×
41
            foreach ($lineErrors as $column => $colErrors) {
×
42
                foreach ($colErrors as $error) {
×
43
                    $filename = str_replace('"', '\"', $report['filename']);
×
44
                    $message  = str_replace('"', '\"', $error['message']);
×
45
                    $type     = strtolower($error['type']);
×
46
                    $source   = $error['source'];
×
47
                    $severity = $error['severity'];
×
48
                    $fixable  = (int) $error['fixable'];
×
49
                    echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity,$fixable".PHP_EOL;
×
50
                }
51
            }
52
        }
53

54
        return true;
×
55

56
    }//end generateFileReport()
57

58

59
    /**
60
     * Generates a csv report.
61
     *
62
     * @param string $cachedData    Any partial report data that was returned from
63
     *                              generateFileReport during the run.
64
     * @param int    $totalFiles    Total number of files processed during the run.
65
     * @param int    $totalErrors   Total number of errors found during the run.
66
     * @param int    $totalWarnings Total number of warnings found during the run.
67
     * @param int    $totalFixable  Total number of problems that can be fixed.
68
     * @param bool   $showSources   Show sources?
69
     * @param int    $width         Maximum allowed line width.
70
     * @param bool   $interactive   Are we running in interactive mode?
71
     * @param bool   $toScreen      Is the report being printed to screen?
72
     *
73
     * @return void
74
     */
75
    public function generate(
×
76
        $cachedData,
77
        $totalFiles,
78
        $totalErrors,
79
        $totalWarnings,
80
        $totalFixable,
81
        $showSources=false,
82
        $width=80,
83
        $interactive=false,
84
        $toScreen=true
85
    ) {
86
        echo 'File,Line,Column,Type,Message,Source,Severity,Fixable'.PHP_EOL;
×
87
        echo $cachedData;
×
88

89
    }//end generate()
90

91

92
}//end class
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc