~ubuntu-branches/ubuntu/vivid/php-codesniffer/vivid

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.5.4/CodeSniffer/Reports/Summary.php

  • Committer: Package Import Robot
  • Author(s): David Prévot, Greg Sherwood, Alexey, Emily, David Prévot
  • Date: 2014-09-26 13:44:35 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140926134435-wvjq16miqq4d60y0
Tags: 1.5.5-1
[ Greg Sherwood ]
* Improved closure support in Generic ScopeIndentSniff
* Improved indented PHP tag support in Generic ScopeIndentSniff
* Standards can now be located within hidden directories
 (further fix for bug #20323)
* Fixed bug #20373 : Inline comment sniff tab handling way
* Fixed bug #20378 : Report appended to existing file if no errors
  found in run
* Fixed bug #20381 : Invalid "Comment closer must be on a new line"
* PHP tokenizer no longer converts class/function names to special
  tokens types
* Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore
  thrown if first block comment
* Squiz and PEAR FunctionCommentSnif now support _()
* PEAR ValidFunctionNameSniff no longer throws an error for _()
* Fixed bug #248 : FunctionCommentSniff expects ampersand on param name
* Fixed bug #248 in Squiz sniff as well
* Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff
* Prepare for 1.5.5 release

[ Alexey ]
* Allowed single undersored methods and functions

[ Emily ]
* Added var_dump to discouraged functions sniff

[ David Prévot ]
* Revert "Add XS-Testsuite still needed for ci.d.n"
* Add self to uploaders
* Bump standards version to 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Summary report for PHP_CodeSniffer.
4
 
 *
5
 
 * PHP version 5
6
 
 *
7
 
 * @category  PHP
8
 
 * @package   PHP_CodeSniffer
9
 
 * @author    Gabriele Santini <gsantini@sqli.com>
10
 
 * @author    Greg Sherwood <gsherwood@squiz.net>
11
 
 * @copyright 2009-2014 SQLI <www.sqli.com>
12
 
 * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
 
 * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
 
 * @link      http://pear.php.net/package/PHP_CodeSniffer
15
 
 */
16
 
 
17
 
/**
18
 
 * Summary report for PHP_CodeSniffer.
19
 
 *
20
 
 * PHP version 5
21
 
 *
22
 
 * @category  PHP
23
 
 * @package   PHP_CodeSniffer
24
 
 * @author    Gabriele Santini <gsantini@sqli.com>
25
 
 * @author    Greg Sherwood <gsherwood@squiz.net>
26
 
 * @copyright 2009-2014 SQLI <www.sqli.com>
27
 
 * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
 
 * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
 
 * @version   Release: 1.5.4
30
 
 * @link      http://pear.php.net/package/PHP_CodeSniffer
31
 
 */
32
 
class PHP_CodeSniffer_Reports_Summary implements PHP_CodeSniffer_Report
33
 
{
34
 
 
35
 
 
36
 
    /**
37
 
     * Generate a partial report for a single processed file.
38
 
     *
39
 
     * If verbose output is enabled, results are shown for all files, even if
40
 
     * they have no errors or warnings. If verbose output is disabled, we only
41
 
     * show files that have at least one warning or error.
42
 
     *
43
 
     * @param array   $report      Prepared report data.
44
 
     * @param boolean $showSources Show sources?
45
 
     * @param int     $width       Maximum allowed line width.
46
 
     *
47
 
     * @return boolean
48
 
     */
49
 
    public function generateFileReport(
50
 
        $report,
51
 
        $showSources=false,
52
 
        $width=80
53
 
    ) {
54
 
        if (PHP_CODESNIFFER_VERBOSITY === 0
55
 
            && $report['errors'] === 0
56
 
            && $report['warnings'] === 0
57
 
        ) {
58
 
            // Nothing to print.
59
 
            return false;
60
 
        }
61
 
 
62
 
        $width = max($width, 70);
63
 
        $file  = $report['filename'];
64
 
 
65
 
        $padding = ($width - 18 - strlen($file));
66
 
        if ($padding < 0) {
67
 
            $file    = '...'.substr($file, (($padding * -1) + 3));
68
 
            $padding = 0;
69
 
        }
70
 
 
71
 
        echo $file.str_repeat(' ', $padding).'  ';
72
 
        echo $report['errors'];
73
 
        echo str_repeat(' ', (8 - strlen((string) $report['errors'])));
74
 
        echo $report['warnings'];
75
 
        echo PHP_EOL;
76
 
 
77
 
        return true;
78
 
 
79
 
    }//end generateFileReport()
80
 
 
81
 
 
82
 
    /**
83
 
     * Generates a summary of errors and warnings for each file processed.
84
 
     * 
85
 
     * @param string  $cachedData    Any partial report data that was returned from
86
 
     *                               generateFileReport during the run.
87
 
     * @param int     $totalFiles    Total number of files processed during the run.
88
 
     * @param int     $totalErrors   Total number of errors found during the run.
89
 
     * @param int     $totalWarnings Total number of warnings found during the run.
90
 
     * @param boolean $showSources   Show sources?
91
 
     * @param int     $width         Maximum allowed line width.
92
 
     * @param boolean $toScreen      Is the report being printed to screen?
93
 
     *
94
 
     * @return void
95
 
     */
96
 
    public function generate(
97
 
        $cachedData,
98
 
        $totalFiles,
99
 
        $totalErrors,
100
 
        $totalWarnings,
101
 
        $showSources=false,
102
 
        $width=80,
103
 
        $toScreen=true
104
 
    ) {
105
 
        if ($cachedData === '') {
106
 
            return;
107
 
        }
108
 
 
109
 
        echo PHP_EOL.'PHP CODE SNIFFER REPORT SUMMARY'.PHP_EOL;
110
 
        echo str_repeat('-', $width).PHP_EOL;
111
 
        echo 'FILE'.str_repeat(' ', ($width - 20)).'ERRORS  WARNINGS'.PHP_EOL;
112
 
        echo str_repeat('-', $width).PHP_EOL;
113
 
 
114
 
        echo $cachedData;
115
 
 
116
 
        echo str_repeat('-', $width).PHP_EOL;
117
 
        echo 'A TOTAL OF '.$totalErrors.' ERROR(S) ';
118
 
        echo 'AND '.$totalWarnings.' WARNING(S) ';
119
 
 
120
 
        echo 'WERE FOUND IN '.$totalFiles.' FILE(S)'.PHP_EOL;
121
 
        echo str_repeat('-', $width).PHP_EOL.PHP_EOL;
122
 
 
123
 
        if ($toScreen === true
124
 
            && PHP_CODESNIFFER_INTERACTIVE === false
125
 
            && class_exists('PHP_Timer', false) === true
126
 
        ) {
127
 
            echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL;
128
 
        }
129
 
 
130
 
    }//end generate()
131
 
 
132
 
 
133
 
}//end class
134
 
 
135
 
?>