当前位置: 首页>>代码示例>>PHP>>正文


PHP PHP_CodeSniffer_Reporting类代码示例

本文整理汇总了PHP中PHP_CodeSniffer_Reporting的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer_Reporting类的具体用法?PHP PHP_CodeSniffer_Reporting怎么用?PHP PHP_CodeSniffer_Reporting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHP_CodeSniffer_Reporting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * 実行
  *
  * @param string $path パス
  *
  * @return void
  */
 public static function process($path)
 {
     require_once 'PHP/CodeSniffer.php';
     require_once 'PHP/CodeSniffer/Reports/Full.php';
     $phpcs = new PHP_CodeSniffer();
     try {
         $phpcs->process($path, 'BEAR');
         echo "<pre><code>";
         echo "<div class='info'>BEAR Convention</div>";
         $fileViolations = $phpcs->getFilesErrors();
         $report = new PHP_CodeSniffer_Reporting();
         $report->printReport('Summary', $fileViolations, true, null, 120);
         $report->printReport('Full', $fileViolations, false, null, 120);
         echo "</code></pre>";
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:25,代码来源:CodeSniff.php

示例2: process

 /**
  * Run the coding style check
  *
  * @return int
  */
 public function process()
 {
     $this->setDefaultValues();
     \PHP_CodeSniffer_Reporting::startTiming();
     $phpcs = new \PHP_CodeSniffer_CLI();
     $phpcs->checkRequirements();
     $values = $phpcs->getCommandLineValues();
     foreach ($this->defaultValues as $k => $v) {
         if (empty($values[$k])) {
             $values[$k] = $v;
         }
     }
     return $phpcs->process($values);
 }
开发者ID:memaw,项目名称:phpcs,代码行数:19,代码来源:Cli.php

示例3: processFile

 /**
  * Run the code sniffs over a single given file.
  *
  * Processes the file and runs the PHP_CodeSniffer sniffs to verify that it
  * conforms with the standard.
  *
  * @param string $file     The file to process.
  * @param string $contents The contents to parse. If NULL, the content
  *                         is taken from the file system.
  *
  * @return void
  * @throws PHP_CodeSniffer_Exception If the file could not be processed.
  * @see    _processFile()
  */
 public function processFile($file, $contents = null)
 {
     if ($contents === null && file_exists($file) === false) {
         throw new PHP_CodeSniffer_Exception("Source file {$file} does not exist");
     }
     // If the file's path matches one of our ignore patterns, skip it.
     foreach ($this->ignorePatterns as $pattern) {
         $replacements = array('\\,' => ',', '*' => '.*');
         $pattern = strtr($pattern, $replacements);
         if (preg_match("|{$pattern}|i", $file) === 1) {
             return;
         }
     }
     // Before we go and spend time tokenizing this file, just check
     // to see if there is a tag up top to indicate that the whole
     // file should be ignored. It must be on one of the first two lines.
     $firstContent = $contents;
     if ($contents === null) {
         $handle = fopen($file, 'r');
         if ($handle !== false) {
             $firstContent = fgets($handle);
             $firstContent .= fgets($handle);
             fclose($handle);
         }
     }
     if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false) {
         // We are ignoring the whole file.
         if (PHP_CODESNIFFER_VERBOSITY > 0) {
             echo 'Ignoring ' . basename($file) . PHP_EOL;
         }
         return;
     }
     $this->_processFile($file, $contents);
     if (PHP_CODESNIFFER_INTERACTIVE === false) {
         return;
     }
     /*
         Running interactively.
         Print the error report for the current file and then wait for user input.
     */
     $reporting = new PHP_CodeSniffer_Reporting();
     $cliValues = $this->cli->getCommandLineValues();
     // Get current violations and then clear the list to make sure
     // we only print violations for a single file each time.
     $numErrors = null;
     while ($numErrors !== 0) {
         $filesViolations = $this->getFilesErrors();
         $this->files = array();
         $numErrors = $reporting->printReport($cliValues['report'], $filesViolations, $cliValues['showSources'], '', $cliValues['reportWidth']);
         if ($numErrors === 0) {
             continue;
         }
         echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
         $input = fgets(STDIN);
         $input = trim($input);
         switch ($input) {
             case 's':
                 break;
             case 'q':
                 exit(0);
                 break;
             default:
                 // Repopulate the sniffs because some of them save their state
                 // and only clear it when the file changes, but we are rechecking
                 // the same file.
                 $this->populateTokenListeners();
                 $this->_processFile($file, $contents);
                 break;
         }
     }
     //end while
 }
开发者ID:resid,项目名称:PHP_CodeSniffer,代码行数:86,代码来源:CodeSniffer.php

示例4: define

 * Run the code checker from the command-line.
 *
 * @package    local
 * @subpackage codechecker
 * @copyright  2011 The Open University
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('CLI_SCRIPT', true);
require dirname(__FILE__) . '/../../config.php';
require_once $CFG->libdir . '/clilib.php';
require_once $CFG->dirroot . '/local/codechecker/locallib.php';
// Get the command-line options.
list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help'));
if (count($unrecognized) != 1) {
    $options['help'] = true;
} else {
    $path = clean_param(reset($unrecognized), PARAM_PATH);
}
if ($options['help']) {
    echo get_string('clihelp', 'local_codechecker'), "\n";
    die;
}
raise_memory_limit(MEMORY_HUGE);
$standard = $CFG->dirroot . str_replace('/', DIRECTORY_SEPARATOR, '/local/codechecker/moodle');
$phpcs = new PHP_CodeSniffer(1);
$phpcs->setCli(new local_codechecker_codesniffer_cli());
$phpcs->setIgnorePatterns(local_codesniffer_get_ignores());
$numerrors = $phpcs->process(local_codechecker_clean_path($CFG->dirroot . '/' . trim($path, '/')), local_codechecker_clean_path($standard));
$reporting = new PHP_CodeSniffer_Reporting();
$problems = $phpcs->getFilesErrors();
$reporting->printReport('full', $problems, false, null);
开发者ID:ravivare,项目名称:moodle-local_codechecker,代码行数:31,代码来源:run.php

示例5: printErrorReport

 /**
  * Prints the error report for the run.
  *
  * Note that this function may actually print multiple reports
  * as the user may have specified a number of output formats.
  *
  * @param PHP_CodeSniffer $phpcs       The PHP_CodeSniffer object containing
  *                                     the errors.
  * @param array           $reports     A list of reports to print.
  * @param bool            $showSources TRUE if report should show error sources
  *                                     (not used by all reports).
  * @param string          $reportFile  A default file to log report output to.
  * @param int             $reportWidth How wide the screen reports should be.
  *
  * @return int The number of error and warning messages shown.
  */
 public function printErrorReport(PHP_CodeSniffer $phpcs, $reports, $showSources, $reportFile, $reportWidth)
 {
     $reporting = new PHP_CodeSniffer_Reporting();
     $filesViolations = $phpcs->getFilesErrors();
     if (empty($reports) === true) {
         $reports['full'] = $reportFile;
     }
     $errors = 0;
     $toScreen = false;
     foreach ($reports as $report => $output) {
         if ($output === null) {
             $output = $reportFile;
         }
         if ($reportFile === null) {
             $toScreen = true;
         }
         // We don't add errors here because the number of
         // errors reported by each report type will always be the
         // same, so we really just need 1 number.
         $errors = $reporting->printReport($report, $filesViolations, $showSources, $output, $reportWidth);
     }
     // Only print PHP_Timer output if no reports were
     // printed to the screen so we don't put additional output
     // in something like an XML report. If we are printing to screen,
     // the report types would have already worked out who should
     // print the timer info.
     if ($toScreen === false && PHP_CODESNIFFER_INTERACTIVE === false && class_exists('PHP_Timer', false) === true) {
         echo PHP_Timer::resourceUsage() . PHP_EOL . PHP_EOL;
     }
     // They should all return the same value, so it
     // doesn't matter which return value we end up using.
     return $errors;
 }
开发者ID:CobaltBlueDW,项目名称:oddsandends,代码行数:49,代码来源:CLI.php

示例6: printErrorReport

 /**
  * Prints the error report for the run.
  *
  * Note that this function may actually print multiple reports
  * as the user may have specified a number of output formats.
  *
  * @param PHP_CodeSniffer $phpcs       The PHP_CodeSniffer object containing
  *                                     the errors.
  * @param array           $reports     A list of reports to print.
  * @param bool            $showSources TRUE if report should show error sources
  *                                     (not used by all reports).
  * @param string          $reportFile  A default file to log report output to.
  * @param int             $reportWidth How wide the screen reports should be.
  *
  * @return int The number of error and warning messages shown.
  */
 public function printErrorReport(PHP_CodeSniffer $phpcs, $reports, $showSources, $reportFile, $reportWidth)
 {
     if (empty($reports) === true) {
         $reports['full'] = $reportFile;
     }
     $errors = 0;
     $warnings = 0;
     $toScreen = false;
     foreach ($reports as $report => $output) {
         if ($output === null) {
             $output = $reportFile;
         }
         if ($reportFile === null) {
             $toScreen = true;
         }
         // We don't add errors here because the number of
         // errors reported by each report type will always be the
         // same, so we really just need 1 number.
         $result = $phpcs->reporting->printReport($report, $showSources, $this->values, $output, $reportWidth);
         $errors = $result['errors'];
         $warnings = $result['warnings'];
     }
     //end foreach
     // Only print timer output if no reports were
     // printed to the screen so we don't put additional output
     // in something like an XML report. If we are printing to screen,
     // the report types would have already worked out who should
     // print the timer info.
     if (PHP_CODESNIFFER_INTERACTIVE === false && ($toScreen === false || $errors + $warnings === 0 && $this->values['showProgress'] === true)) {
         PHP_CodeSniffer_Reporting::printRunTime();
     }
     // They should all return the same value, so it
     // doesn't matter which return value we end up using.
     $ignoreWarnings = PHP_CodeSniffer::getConfigData('ignore_warnings_on_exit');
     $ignoreErrors = PHP_CodeSniffer::getConfigData('ignore_errors_on_exit');
     $return = $errors + $warnings;
     if ($ignoreErrors !== null) {
         $ignoreErrors = (bool) $ignoreErrors;
         if ($ignoreErrors === true) {
             $return -= $errors;
         }
     }
     if ($ignoreWarnings !== null) {
         $ignoreWarnings = (bool) $ignoreWarnings;
         if ($ignoreWarnings === true) {
             $return -= $warnings;
         }
     }
     return $return;
 }
开发者ID:ghermans,项目名称:PHP_CodeSniffer,代码行数:66,代码来源:CLI.php

示例7: generate


//.........这里部分代码省略.........
 public function generate($cachedData, $totalFiles, $totalErrors, $totalWarnings, $totalFixable, $showSources = false, $width = 80, $toScreen = true)
 {
     $width = max($width, 70);
     if (empty($this->_sourceCache) === true) {
         // Nothing to show.
         return;
     }
     asort($this->_sourceCache);
     $this->_sourceCache = array_reverse($this->_sourceCache);
     echo PHP_EOL . 'PHP CODE SNIFFER VIOLATION SOURCE SUMMARY' . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL;
     if ($showSources === true) {
         if ($totalFixable > 0) {
             echo '    SOURCE' . str_repeat(' ', $width - 15) . 'COUNT' . PHP_EOL;
         } else {
             echo 'SOURCE' . str_repeat(' ', $width - 11) . 'COUNT' . PHP_EOL;
         }
     } else {
         if ($totalFixable > 0) {
             echo '    STANDARD  CATEGORY            SNIFF' . str_repeat(' ', $width - 44) . 'COUNT' . PHP_EOL;
         } else {
             echo 'STANDARD  CATEGORY            SNIFF' . str_repeat(' ', $width - 40) . 'COUNT' . PHP_EOL;
         }
     }
     echo str_repeat('-', $width) . PHP_EOL;
     $fixableSources = 0;
     $maxSniffWidth = 37;
     if ($totalFixable > 0) {
         $maxSniffWidth += 4;
     }
     foreach ($this->_sourceCache as $source => $sourceData) {
         if ($totalFixable > 0) {
             echo '[';
             if ($sourceData['fixable'] === true) {
                 echo 'x';
                 $fixableSources++;
             } else {
                 echo ' ';
             }
             echo '] ';
         }
         if ($showSources === true) {
             echo $source;
             if ($totalFixable > 0) {
                 echo str_repeat(' ', $width - 9 - strlen($source));
             } else {
                 echo str_repeat(' ', $width - 5 - strlen($source));
             }
         } else {
             $parts = explode('.', $source);
             if ($parts[0] === 'Internal') {
                 $parts[2] = $parts[1];
                 $parts[1] = '';
             }
             if (strlen($parts[0]) > 8) {
                 $parts[0] = substr($parts[0], 0, (strlen($parts[0]) - 8) * -1);
             }
             echo $parts[0] . str_repeat(' ', 10 - strlen($parts[0]));
             $category = $this->makeFriendlyName($parts[1]);
             if (strlen($category) > 18) {
                 $category = substr($category, 0, (strlen($category) - 18) * -1);
             }
             echo $category . str_repeat(' ', 20 - strlen($category));
             $sniff = $this->makeFriendlyName($parts[2]);
             if (isset($parts[3]) === true) {
                 $name = $this->makeFriendlyName($parts[3]);
                 $name[0] = strtolower($name[0]);
                 $sniff .= ' ' . $name;
             }
             if (strlen($sniff) > $width - $maxSniffWidth) {
                 $sniff = substr($sniff, 0, $width - $maxSniffWidth - strlen($sniff));
             }
             if ($totalFixable > 0) {
                 echo $sniff . str_repeat(' ', $width - 39 - strlen($sniff));
             } else {
                 echo $sniff . str_repeat(' ', $width - 35 - strlen($sniff));
             }
         }
         //end if
         echo $sourceData['count'] . PHP_EOL;
     }
     //end foreach
     echo str_repeat('-', $width) . PHP_EOL;
     echo 'A TOTAL OF ' . ($totalErrors + $totalWarnings) . ' SNIFF VIOLATION';
     if ($totalErrors + $totalWarnings > 1) {
         echo 'S';
     }
     echo ' WERE FOUND IN ' . count($this->_sourceCache) . ' SOURCE';
     if (count($this->_sourceCache) !== 1) {
         echo 'S';
     }
     if ($totalFixable > 0) {
         echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
         echo "PHPCBF CAN FIX THE {$fixableSources} MARKED SOURCES AUTOMATICALLY ({$totalFixable} VIOLATIONS IN TOTAL)";
     }
     echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
     if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
         PHP_CodeSniffer_Reporting::printRunTime();
     }
 }
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:101,代码来源:Source.php

示例8: generate


//.........这里部分代码省略.........
     }
     $width = min($width, $maxLength + 30);
     $width = max($width, 70);
     arsort($this->_authorCache);
     echo PHP_EOL . "[1m" . 'PHP CODE SNIFFER ' . $this->reportName . ' BLAME SUMMARY' . "[0m" . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL . "[1m";
     if ($showSources === true) {
         echo 'AUTHOR   SOURCE' . str_repeat(' ', $width - 43) . '(Author %) (Overall %) COUNT' . PHP_EOL;
         echo str_repeat('-', $width) . PHP_EOL;
     } else {
         echo 'AUTHOR' . str_repeat(' ', $width - 34) . '(Author %) (Overall %) COUNT' . PHP_EOL;
         echo str_repeat('-', $width) . PHP_EOL;
     }
     echo "[0m";
     if ($showSources === true) {
         $maxSniffWidth = $width - 15;
         if ($totalFixable > 0) {
             $maxSniffWidth -= 4;
         }
     }
     $fixableSources = 0;
     foreach ($this->_authorCache as $author => $count) {
         if ($this->_praiseCache[$author]['good'] === 0) {
             $percent = 0;
         } else {
             $total = $this->_praiseCache[$author]['bad'] + $this->_praiseCache[$author]['good'];
             $percent = round($this->_praiseCache[$author]['bad'] / $total * 100, 2);
         }
         $overallPercent = '(' . round($count / $errorsShown * 100, 2) . ')';
         $authorPercent = '(' . $percent . ')';
         $line = str_repeat(' ', 6 - strlen($count)) . $count;
         $line = str_repeat(' ', 12 - strlen($overallPercent)) . $overallPercent . $line;
         $line = str_repeat(' ', 11 - strlen($authorPercent)) . $authorPercent . $line;
         $line = $author . str_repeat(' ', $width - strlen($author) - strlen($line)) . $line;
         if ($showSources === true) {
             $line = "[1m{$line}[0m";
         }
         echo $line . PHP_EOL;
         if ($showSources === true && isset($this->_sourceCache[$author]) === true) {
             $errors = $this->_sourceCache[$author];
             asort($errors);
             $errors = array_reverse($errors);
             foreach ($errors as $source => $sourceData) {
                 if ($source === 'count') {
                     continue;
                 }
                 $count = $sourceData['count'];
                 $srcLength = strlen($source);
                 if ($srcLength > $maxSniffWidth) {
                     $source = substr($source, 0, $maxSniffWidth);
                 }
                 $line = str_repeat(' ', 5 - strlen($count)) . $count;
                 echo '         ';
                 if ($totalFixable > 0) {
                     echo '[';
                     if ($sourceData['fixable'] === true) {
                         echo 'x';
                         $fixableSources++;
                     } else {
                         echo ' ';
                     }
                     echo '] ';
                 }
                 echo $source;
                 if ($totalFixable > 0) {
                     echo str_repeat(' ', $width - 18 - strlen($source));
                 } else {
                     echo str_repeat(' ', $width - 14 - strlen($source));
                 }
                 echo $line . PHP_EOL;
             }
             //end foreach
         }
         //end if
     }
     //end foreach
     echo str_repeat('-', $width) . PHP_EOL;
     echo "[1m" . 'A TOTAL OF ' . $errorsShown . ' SNIFF VIOLATION';
     if ($errorsShown !== 1) {
         echo 'S';
     }
     echo ' WERE COMMITTED BY ' . count($this->_authorCache) . ' AUTHOR';
     if (count($this->_authorCache) !== 1) {
         echo 'S';
     }
     echo "[0m";
     if ($totalFixable > 0) {
         if ($showSources === true) {
             echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
             echo "[1mPHPCBF CAN FIX THE {$fixableSources} MARKED SOURCES AUTOMATICALLY ({$totalFixable} VIOLATIONS IN TOTAL)[0m";
         } else {
             echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
             echo "[1mPHPCBF CAN FIX {$totalFixable} OF THESE SNIFF VIOLATIONS AUTOMATICALLY[0m";
         }
     }
     echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
     if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
         PHP_CodeSniffer_Reporting::printRunTime();
     }
 }
开发者ID:squizlabs,项目名称:php_codesniffer,代码行数:101,代码来源:VersionControl.php

示例9: generate

 /**
  * Generates a summary of errors and warnings for each file processed.
  *
  * @param string  $cachedData    Any partial report data that was returned from
  *                               generateFileReport during the run.
  * @param int     $totalFiles    Total number of files processed during the run.
  * @param int     $totalErrors   Total number of errors found during the run.
  * @param int     $totalWarnings Total number of warnings found during the run.
  * @param int     $totalFixable  Total number of problems that can be fixed.
  * @param boolean $showSources   Show sources?
  * @param int     $width         Maximum allowed line width.
  * @param boolean $toScreen      Is the report being printed to screen?
  *
  * @return void
  */
 public function generate($cachedData, $totalFiles, $totalErrors, $totalWarnings, $totalFixable, $showSources = false, $width = 80, $toScreen = true)
 {
     if (empty($this->_reportFiles) === true) {
         return;
     }
     // Make sure the report width isn't too big.
     $maxLength = 0;
     foreach ($this->_reportFiles as $file => $data) {
         $maxLength = max($maxLength, $data['strlen']);
     }
     $width = min($width, $maxLength + 21);
     $width = max($width, 70);
     echo PHP_EOL . "[1m" . 'PHP CODE SNIFFER REPORT SUMMARY' . "[0m" . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL;
     echo "[1m" . 'FILE' . str_repeat(' ', $width - 20) . 'ERRORS  WARNINGS' . "[0m" . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL;
     foreach ($this->_reportFiles as $file => $data) {
         $padding = $width - 18 - $data['strlen'];
         if ($padding < 0) {
             $file = '...' . substr($file, $padding * -1 + 3);
             $padding = 0;
         }
         echo $file . str_repeat(' ', $padding) . '  ';
         if ($data['errors'] !== 0) {
             echo "[31m" . $data['errors'] . "[0m";
             echo str_repeat(' ', 8 - strlen((string) $data['errors']));
         } else {
             echo '0       ';
         }
         if ($data['warnings'] !== 0) {
             echo "[33m" . $data['warnings'] . "[0m";
         } else {
             echo '0';
         }
         echo PHP_EOL;
     }
     //end foreach
     echo str_repeat('-', $width) . PHP_EOL;
     echo "[1mA TOTAL OF {$totalErrors} ERROR";
     if ($totalErrors !== 1) {
         echo 'S';
     }
     echo ' AND ' . $totalWarnings . ' WARNING';
     if ($totalWarnings !== 1) {
         echo 'S';
     }
     echo ' WERE FOUND IN ' . $totalFiles . ' FILE';
     if ($totalFiles !== 1) {
         echo 'S';
     }
     echo "[0m";
     if ($totalFixable > 0) {
         echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
         echo "[1mPHPCBF CAN FIX {$totalFixable} OF THESE SNIFF VIOLATIONS AUTOMATICALLY[0m";
     }
     echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
     if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
         PHP_CodeSniffer_Reporting::printRunTime();
     }
 }
开发者ID:itliuchang,项目名称:test,代码行数:75,代码来源:Summary.php

示例10: generate

 /**
  * Generates a summary of errors and warnings for each file processed.
  *
  * @param string  $cachedData    Any partial report data that was returned from
  *                               generateFileReport during the run.
  * @param int     $totalFiles    Total number of files processed during the run.
  * @param int     $totalErrors   Total number of errors found during the run.
  * @param int     $totalWarnings Total number of warnings found during the run.
  * @param int     $totalFixable  Total number of problems that can be fixed.
  * @param boolean $showSources   Show sources?
  * @param int     $width         Maximum allowed line width.
  * @param boolean $toScreen      Is the report being printed to screen?
  *
  * @return void
  */
 public function generate($cachedData, $totalFiles, $totalErrors, $totalWarnings, $totalFixable, $showSources = false, $width = 80, $toScreen = true)
 {
     if ($cachedData === '') {
         return;
     }
     echo PHP_EOL . 'PHP CODE SNIFFER REPORT SUMMARY' . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL;
     echo 'FILE' . str_repeat(' ', $width - 20) . 'ERRORS  WARNINGS' . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL;
     echo $cachedData;
     echo str_repeat('-', $width) . PHP_EOL;
     echo 'A TOTAL OF ' . $totalErrors . ' ERROR';
     if ($totalErrors !== 1) {
         echo 'S';
     }
     echo ' AND ' . $totalWarnings . ' WARNING';
     if ($totalWarnings !== 1) {
         echo 'S';
     }
     echo ' WERE FOUND IN ' . $totalFiles . ' FILE';
     if ($totalFiles !== 1) {
         echo 'S';
     }
     if ($totalFixable > 0) {
         echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
         echo 'PHPCBF CAN FIX ' . $totalFixable . ' OF THESE SNIFF VIOLATIONS AUTOMATICALLY';
     }
     echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
     if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
         PHP_CodeSniffer_Reporting::printRunTime();
     }
 }
开发者ID:eredi93,项目名称:forms,代码行数:47,代码来源:Summary.php

示例11: printErrorReport

 /**
  * Prints the error report.
  *
  * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object containing
  *                               the errors.
  *
  * @return int The number of error and warning messages shown.
  */
 protected function printErrorReport($phpcs)
 {
     if ($this->showSniffs) {
         $sniffs = $phpcs->getSniffs();
         $sniffStr = '';
         foreach ($sniffs as $sniff) {
             $sniffStr .= '- ' . $sniff . PHP_EOL;
         }
         $this->log('The list of used sniffs (#' . count($sniffs) . '): ' . PHP_EOL . $sniffStr, Project::MSG_INFO);
     }
     $filesViolations = $phpcs->getFilesErrors();
     $reporting = new PHP_CodeSniffer_Reporting();
     $report = $reporting->prepare($filesViolations, $this->showWarnings);
     // process output
     foreach ($this->formatters as $fe) {
         switch ($fe->getType()) {
             case 'default':
                 // default format goes to logs, no buffering
                 $this->outputCustomFormat($report);
                 $fe->setUseFile(false);
                 break;
             default:
                 $reportFile = '';
                 if ($fe->getUseFile()) {
                     $reportFile = $fe->getOutfile()->getPath();
                     ob_start();
                 }
                 $reporting->printReport($fe->getType(), $filesViolations, $this->showWarnings, $this->showSources, $reportFile, $this->reportWidth);
                 // reporting class uses ob_end_flush(), but we don't want
                 // an output if we use a file
                 if ($fe->getUseFile()) {
                     ob_end_clean();
                 }
                 break;
         }
     }
     return $report;
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:46,代码来源:PhpCodeSnifferTask.php

示例12: printErrorReport

 /**
  * Prints the error report.
  *
  * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object containing
  *                               the errors.
  *
  * @return int The number of error and warning messages shown.
  */
 protected function printErrorReport($phpcs)
 {
     if ($this->showSniffs) {
         $sniffs = $phpcs->getSniffs();
         $sniffStr = '';
         foreach ($sniffs as $sniff) {
             $sniffStr .= '- ' . $sniff . PHP_EOL;
         }
         $this->log('The list of used sniffs (#' . count($sniffs) . '): ' . PHP_EOL . $sniffStr, Project::MSG_INFO);
     }
     $filesViolations = $phpcs->getFilesErrors();
     $reporting = new PHP_CodeSniffer_Reporting();
     $report = $reporting->prepare($filesViolations, $this->showWarnings);
     // process output
     foreach ($this->formatters as $fe) {
         switch ($fe->getType()) {
             case 'default':
                 // default format goes to logs, no buffering
                 $this->outputCustomFormat($report);
                 $fe->setUseFile(false);
                 break;
             default:
                 $reportFile = null;
                 if ($fe->getUseFile()) {
                     $reportFile = $fe->getOutfile();
                     ob_start();
                 }
                 // Determine number of parameters required to
                 // ensure backwards compatibility
                 $rm = new ReflectionMethod('PHP_CodeSniffer_Reporting', 'printReport');
                 if ($rm->getNumberOfParameters() == 5) {
                     $reporting->printReport($fe->getType(), $filesViolations, $this->showSources, $reportFile, $this->reportWidth);
                 } else {
                     $reporting->printReport($fe->getType(), $filesViolations, $this->showWarnings, $this->showSources, $reportFile, $this->reportWidth);
                 }
                 // reporting class uses ob_end_flush(), but we don't want
                 // an output if we use a file
                 if ($fe->getUseFile()) {
                     ob_end_clean();
                 }
                 break;
         }
     }
     return $report;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:53,代码来源:PhpCodeSnifferTask.php

示例13: generateFileReport

 /** {@inheritDoc} */
 public function generateFileReport($report, PHP_CodeSniffer_File $phpcsFile, $showSources = false, $width = 80)
 {
     $diff = $this->getStagedDiff();
     $changes = $this->getChanges($diff);
     $report = $this->filterReport($report, $changes);
     $reporting = new PHP_CodeSniffer_Reporting();
     $actual = $reporting->factory($this->reportType);
     return $actual->generateFileReport($report, $phpcsFile, $showSources, $width);
 }
开发者ID:morozov,项目名称:diff-sniffer-core,代码行数:10,代码来源:DiffSniffer.php

示例14: generate


//.........这里部分代码省略.........
         $maxLength = max($maxLength, $data['strlen']);
     }
     if ($showSources === true) {
         $width = min($width, $maxLength + 11);
     } else {
         $width = min($width, $maxLength + 41);
     }
     $width = max($width, 70);
     asort($this->_sourceCache);
     $this->_sourceCache = array_reverse($this->_sourceCache);
     echo PHP_EOL . "[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY[0m" . PHP_EOL;
     echo str_repeat('-', $width) . PHP_EOL . "[1m";
     if ($showSources === true) {
         if ($totalFixable > 0) {
             echo '    SOURCE' . str_repeat(' ', $width - 15) . 'COUNT' . PHP_EOL;
         } else {
             echo 'SOURCE' . str_repeat(' ', $width - 11) . 'COUNT' . PHP_EOL;
         }
     } else {
         if ($totalFixable > 0) {
             echo '    STANDARD  CATEGORY            SNIFF' . str_repeat(' ', $width - 44) . 'COUNT' . PHP_EOL;
         } else {
             echo 'STANDARD  CATEGORY            SNIFF' . str_repeat(' ', $width - 40) . 'COUNT' . PHP_EOL;
         }
     }
     echo "[0m" . str_repeat('-', $width) . PHP_EOL;
     $fixableSources = 0;
     if ($showSources === true) {
         $maxSniffWidth = $width - 7;
     } else {
         $maxSniffWidth = $width - 37;
     }
     if ($totalFixable > 0) {
         $maxSniffWidth -= 4;
     }
     foreach ($this->_sourceCache as $source => $sourceData) {
         if ($totalFixable > 0) {
             echo '[';
             if ($sourceData['fixable'] === true) {
                 echo 'x';
                 $fixableSources++;
             } else {
                 echo ' ';
             }
             echo '] ';
         }
         if ($showSources === true) {
             if ($sourceData['strlen'] > $maxSniffWidth) {
                 $source = substr($source, 0, $maxSniffWidth);
             }
             echo $source;
             if ($totalFixable > 0) {
                 echo str_repeat(' ', $width - 9 - strlen($source));
             } else {
                 echo str_repeat(' ', $width - 5 - strlen($source));
             }
         } else {
             $parts = $sourceData['parts'];
             if (strlen($parts[0]) > 8) {
                 $parts[0] = substr($parts[0], 0, (strlen($parts[0]) - 8) * -1);
             }
             echo $parts[0] . str_repeat(' ', 10 - strlen($parts[0]));
             $category = $parts[1];
             if (strlen($category) > 18) {
                 $category = substr($category, 0, (strlen($category) - 18) * -1);
             }
             echo $category . str_repeat(' ', 20 - strlen($category));
             $sniff = $parts[2];
             if (strlen($sniff) > $maxSniffWidth) {
                 $sniff = substr($sniff, 0, $maxSniffWidth);
             }
             if ($totalFixable > 0) {
                 echo $sniff . str_repeat(' ', $width - 39 - strlen($sniff));
             } else {
                 echo $sniff . str_repeat(' ', $width - 35 - strlen($sniff));
             }
         }
         //end if
         echo $sourceData['count'] . PHP_EOL;
     }
     //end foreach
     echo str_repeat('-', $width) . PHP_EOL;
     echo "[1m" . 'A TOTAL OF ' . ($totalErrors + $totalWarnings) . ' SNIFF VIOLATION';
     if ($totalErrors + $totalWarnings > 1) {
         echo 'S';
     }
     echo ' WERE FOUND IN ' . count($this->_sourceCache) . ' SOURCE';
     if (count($this->_sourceCache) !== 1) {
         echo 'S';
     }
     echo "[0m";
     if ($totalFixable > 0) {
         echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
         echo "[1mPHPCBF CAN FIX THE {$fixableSources} MARKED SOURCES AUTOMATICALLY ({$totalFixable} VIOLATIONS IN TOTAL)[0m";
     }
     echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
     if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
         PHP_CodeSniffer_Reporting::printRunTime();
     }
 }
开发者ID:lunnlew,项目名称:Norma_Code,代码行数:101,代码来源:Source.php

示例15: report

 /**
  * Print a report into a file
  * 
  * @param string $file       File path
  * @param string $reportType One of full xml checkstyle csv emacs source summary svnblame gitblame
  *
  * @return int               Error and warning count
  */
 function report($file, $reportType = "xml")
 {
     // Create the file
     $reportPath = $this->makeReportPath($file, $reportType);
     CMbPath::forceDir(dirname($reportPath));
     touch($reportPath);
     // Build the report
     $reporting = new PHP_CodeSniffer_Reporting();
     return $reporting->printReport($reportType, $this->getFilesErrors(), $showSources = true, $reportPath, $reportWidth = 120);
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:18,代码来源:CMbCodeSniffer.class.php


注:本文中的PHP_CodeSniffer_Reporting类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。