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


PHP PHP_CodeSniffer_Reporting::startTiming方法代码示例

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


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

示例1: 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

示例2: runphpcbf

 /**
  * Run the PHPCBF script.
  *
  * @return array
  */
 public function runphpcbf()
 {
     if (defined('PHP_CODESNIFFER_CBF') === false) {
         define('PHP_CODESNIFFER_CBF', true);
     }
     if (is_file(dirname(__FILE__) . '/../CodeSniffer/Reporting.php') === true) {
         include_once dirname(__FILE__) . '/../CodeSniffer/Reporting.php';
     } else {
         include_once 'PHP/CodeSniffer/Reporting.php';
     }
     PHP_CodeSniffer_Reporting::startTiming();
     $this->checkRequirements();
     $this->dieOnUnknownArg = false;
     // Override some of the command line settings that might break the fixes.
     $cliValues = $this->getCommandLineValues();
     $cliValues['verbosity'] = 0;
     $cliValues['showProgress'] = false;
     $cliValues['generator'] = '';
     $cliValues['explain'] = false;
     $cliValues['interactive'] = false;
     $cliValues['showSources'] = false;
     $cliValues['reportFile'] = null;
     $cliValues['reports'] = array();
     $suffix = '';
     if (isset($cliValues['suffix']) === true) {
         $suffix = $cliValues['suffix'];
     }
     $allowPatch = true;
     if (isset($cliValues['no-patch']) === true || empty($cliValues['files']) === true) {
         // They either asked for this,
         // or they are using STDIN, which can't use diff.
         $allowPatch = false;
     }
     if ($suffix === '' && $allowPatch === true) {
         // Using the diff/patch tools.
         $diffFile = getcwd() . '/phpcbf-fixed.diff';
         $cliValues['reports'] = array('diff' => $diffFile);
         if (file_exists($diffFile) === true) {
             unlink($diffFile);
         }
     } else {
         // Replace the file without the patch command
         // or writing to a file with a new suffix.
         $cliValues['reports'] = array('cbf' => null);
         $cliValues['phpcbf-suffix'] = $suffix;
     }
     $numErrors = $this->process($cliValues);
     if ($suffix === '' && $allowPatch === true) {
         if (file_exists($diffFile) === false) {
             // Nothing to fix.
             if ($numErrors === 0) {
                 // And no errors reported.
                 $exit = 0;
             } else {
                 // Errors we can't fix.
                 $exit = 2;
             }
         } else {
             if (filesize($diffFile) < 10) {
                 // Empty or bad diff file.
                 if ($numErrors === 0) {
                     // And no errors reported.
                     $exit = 0;
                 } else {
                     // Errors we can't fix.
                     $exit = 2;
                 }
             } else {
                 $cmd = "patch -p0 -ui \"{$diffFile}\"";
                 $output = array();
                 $retVal = null;
                 exec($cmd, $output, $retVal);
                 if ($retVal === 0) {
                     // Everything went well.
                     $filesPatched = count($output);
                     echo "Patched {$filesPatched} file";
                     if ($filesPatched > 1) {
                         echo 's';
                     }
                     echo PHP_EOL;
                     $exit = 1;
                 } else {
                     print_r($output);
                     echo "Returned: {$retVal}" . PHP_EOL;
                     $exit = 3;
                 }
             }
             //end if
             unlink($diffFile);
         }
         //end if
     } else {
         // File are being patched manually, so we can't tell
         // how many errors were fixed.
         $exit = 1;
//.........这里部分代码省略.........
开发者ID:ghermans,项目名称:PHP_CodeSniffer,代码行数:101,代码来源:CLI.php


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