當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PHP_CodeSniffer::prepareErrorReport方法代碼示例

本文整理匯總了PHP中PHP_CodeSniffer::prepareErrorReport方法的典型用法代碼示例。如果您正苦於以下問題:PHP PHP_CodeSniffer::prepareErrorReport方法的具體用法?PHP PHP_CodeSniffer::prepareErrorReport怎麽用?PHP PHP_CodeSniffer::prepareErrorReport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PHP_CodeSniffer的用法示例。


在下文中一共展示了PHP_CodeSniffer::prepareErrorReport方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: outputCustomFormat

 /**
  * Outputs the results with a custom format
  * @param PHP_CodeSniffer $codeSniffer
  */
 protected function outputCustomFormat($codeSniffer)
 {
     $report = $codeSniffer->prepareErrorReport($this->showWarnings);
     $files = $report['files'];
     foreach ($files as $file => $attributes) {
         $errors = $attributes['errors'];
         $warnings = $attributes['warnings'];
         $messages = $attributes['messages'];
         if ($errors > 0) {
             $this->log($file . ': ' . $errors . ' error' . ($errors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
             $this->outputCustomFormatMessages($messages, 'ERROR');
         } else {
             $this->log($file . ': No syntax errors detected', Project::MSG_VERBOSE);
         }
         if ($warnings > 0) {
             $this->log($file . ': ' . $warnings . ' warning' . ($warnings > 1 ? 's' : '') . ' detected', Project::MSG_WARN);
             $this->outputCustomFormatMessages($messages, 'WARNING');
         }
     }
     $totalErrors = $report['totals']['errors'];
     $totalWarnings = $report['totals']['warnings'];
     $this->log(count($files) . ' files where checked', Project::MSG_INFO);
     if ($totalErrors > 0) {
         $this->log($totalErrors . ' error' . ($totalErrors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
     } else {
         $this->log('No syntax errors detected', Project::MSG_INFO);
     }
     if ($totalWarnings > 0) {
         $this->log($totalWarnings . ' warning' . ($totalWarnings > 1 ? 's' : '') . ' detected', Project::MSG_INFO);
     }
 }
開發者ID:hunde,項目名稱:bsc,代碼行數:35,代碼來源:PhpCodeSnifferTask.php

示例2: _runPHPCSWithClass

 protected function _runPHPCSWithClass($file)
 {
     // Check the PHP version.
     if (version_compare(PHP_VERSION, '5.1.0') === -1) {
         echo 'ERROR: PEAR_Enforce requires PHP version 5.1.0 or greater.' . "\n";
         exit(2);
     }
     require_once 'PHP/CodeSniffer.php';
     $phpcs = new PHP_CodeSniffer(0, 4);
     $phpcs->process($file, "PEAR", array(), false);
     $results = $phpcs->prepareErrorReport(true);
     $results = $results['files'][$file]['messages'];
     return $results;
 }
開發者ID:nsyed,項目名稱:kvzlib,代碼行數:14,代碼來源:Enforce.php


注:本文中的PHP_CodeSniffer::prepareErrorReport方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。