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


PHP File::getWarnings方法代码示例

本文整理汇总了PHP中PHP_CodeSniffer\Files\File::getWarnings方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getWarnings方法的具体用法?PHP File::getWarnings怎么用?PHP File::getWarnings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHP_CodeSniffer\Files\File的用法示例。


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

示例1: prepareFileReport

 /**
  * Generate summary information to be used during report generation.
  *
  * @param \PHP_CodeSniffer\Files\File $phpcsFile The file that has been processed.
  *
  * @return array
  */
 public function prepareFileReport(File $phpcsFile)
 {
     $report = array('filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath), 'errors' => $phpcsFile->getErrorCount(), 'warnings' => $phpcsFile->getWarningCount(), 'fixable' => $phpcsFile->getFixableCount(), 'messages' => array());
     if ($report['errors'] === 0 && $report['warnings'] === 0) {
         // Prefect score!
         return $report;
     }
     if ($this->config->recordErrors === false) {
         $message = 'Errors are not being recorded but this report requires error messages. ';
         $message .= 'This report will not show the correct information.';
         $report['messages'][1][1] = array(array('message' => $message, 'source' => 'Internal.RecordErrors', 'severity' => 5, 'fixable' => false, 'type' => 'ERROR'));
         return $report;
     }
     $errors = array();
     // Merge errors and warnings.
     foreach ($phpcsFile->getErrors() as $line => $lineErrors) {
         foreach ($lineErrors as $column => $colErrors) {
             $newErrors = array();
             foreach ($colErrors as $data) {
                 $newErrors[] = array('message' => $data['message'], 'source' => $data['source'], 'severity' => $data['severity'], 'fixable' => $data['fixable'], 'type' => 'ERROR');
             }
             $errors[$line][$column] = $newErrors;
         }
         ksort($errors[$line]);
     }
     //end foreach
     foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) {
         foreach ($lineWarnings as $column => $colWarnings) {
             $newWarnings = array();
             foreach ($colWarnings as $data) {
                 $newWarnings[] = array('message' => $data['message'], 'source' => $data['source'], 'severity' => $data['severity'], 'fixable' => $data['fixable'], 'type' => 'WARNING');
             }
             if (isset($errors[$line]) === false) {
                 $errors[$line] = array();
             }
             if (isset($errors[$line][$column]) === true) {
                 $errors[$line][$column] = array_merge($newWarnings, $errors[$line][$column]);
             } else {
                 $errors[$line][$column] = $newWarnings;
             }
         }
         //end foreach
         ksort($errors[$line]);
     }
     //end foreach
     ksort($errors);
     $report['messages'] = $errors;
     return $report;
 }
开发者ID:thekabal,项目名称:tki,代码行数:56,代码来源:Reporter.php


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