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


PHP File::addWarningOnLine方法代码示例

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


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

示例1: process

 /**
  * Processes the tokens that this sniff is interested in.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
  * @param int                  $stackPtr  The position in the stack where
  *                                        the token was found.
  *
  * @return void
  * @throws PHP_CodeSniffer_Exception If jslint.js could not be run
  */
 public function process(File $phpcsFile, $stackPtr)
 {
     $rhinoPath = Config::getExecutablePath('jslint');
     $jslintPath = Config::getExecutablePath('jslint');
     if ($rhinoPath === null || $jslintPath === null) {
         return;
     }
     $fileName = $phpcsFile->getFilename();
     $cmd = "{$rhinoPath} \"{$jslintPath}\" \"{$fileName}\"";
     $msg = exec($cmd, $output, $retval);
     if (is_array($output) === true) {
         foreach ($output as $finding) {
             $matches = array();
             $numMatches = preg_match('/Lint at line ([0-9]+).*:(.*)$/', $finding, $matches);
             if ($numMatches === 0) {
                 continue;
             }
             $line = (int) $matches[1];
             $message = 'jslint says: ' . trim($matches[2]);
             $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool');
         }
     }
     // Ignore the rest of the file.
     return $phpcsFile->numTokens + 1;
 }
开发者ID:thekabal,项目名称:tki,代码行数:35,代码来源:JSLintSniff.php

示例2: process

 /**
  * Processes the tokens that this sniff is interested in.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
  * @param int                  $stackPtr  The position in the stack where
  *                                        the token was found.
  *
  * @return void
  */
 public function process(File $phpcsFile, $stackPtr)
 {
     $jslPath = Config::getExecutablePath('jsl');
     if (is_null($jslPath) === true) {
         return;
     }
     $fileName = $phpcsFile->getFilename();
     $cmd = '"' . $jslPath . '" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process "' . $fileName . '"';
     $msg = exec($cmd, $output, $retval);
     // Variable $exitCode is the last line of $output if no error occurs, on
     // error it is numeric. Try to handle various error conditions and
     // provide useful error reporting.
     if ($retval === 2 || $retval === 4) {
         if (is_array($output) === true) {
             $msg = join('\\n', $output);
         }
         throw new RuntimeException("Failed invoking JavaScript Lint, retval was [{$retval}], output was [{$msg}]");
     }
     if (is_array($output) === true) {
         foreach ($output as $finding) {
             $split = strpos($finding, ':');
             $line = substr($finding, 0, $split);
             $message = substr($finding, $split + 1);
             $phpcsFile->addWarningOnLine(trim($message), $line, 'ExternalTool');
         }
     }
     // Ignore the rest of the file.
     return $phpcsFile->numTokens + 1;
 }
开发者ID:thekabal,项目名称:tki,代码行数:38,代码来源:JavaScriptLintSniff.php

示例3: process

 /**
  * Processes the tokens that this sniff is interested in.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
  * @param int                  $stackPtr  The position in the stack where
  *                                        the token was found.
  *
  * @return void
  */
 public function process(File $phpcsFile, $stackPtr)
 {
     $csslintPath = Config::getExecutablePath('csslint');
     if ($csslintPath === null) {
         return;
     }
     $fileName = $phpcsFile->getFilename();
     $cmd = $csslintPath . ' ' . escapeshellarg($fileName);
     exec($cmd, $output, $retval);
     if (is_array($output) === false) {
         return;
     }
     $count = count($output);
     for ($i = 0; $i < $count; $i++) {
         $matches = array();
         $numMatches = preg_match('/(error|warning) at line (\\d+)/', $output[$i], $matches);
         if ($numMatches === 0) {
             continue;
         }
         $line = (int) $matches[2];
         $message = 'csslint says: ' . $output[$i + 1];
         // First line is message with error line and error code.
         // Second is error message.
         // Third is wrong line in file.
         // Fourth is empty line.
         $i += 4;
         $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool');
     }
     //end for
     // Ignore the rest of the file.
     return $phpcsFile->numTokens + 1;
 }
开发者ID:thekabal,项目名称:tki,代码行数:41,代码来源:CSSLintSniff.php

示例4: process

 /**
  * Processes the tokens that this sniff is interested in.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
  * @param int                  $stackPtr  The position in the stack where
  *                                        the token was found.
  *
  * @return int
  */
 public function process(File $phpcsFile, $stackPtr)
 {
     $analyzerPath = Config::getExecutablePath('zend_ca');
     if (is_null($analyzerPath) === true) {
         return;
     }
     $fileName = $phpcsFile->getFilename();
     // In the command, 2>&1 is important because the code analyzer sends its
     // findings to stderr. $output normally contains only stdout, so using 2>&1
     // will pipe even stderr to stdout.
     $cmd = $analyzerPath . ' ' . $fileName . ' 2>&1';
     // There is the possibility to pass "--ide" as an option to the analyzer.
     // This would result in an output format which would be easier to parse.
     // The problem here is that no cleartext error messages are returnwd; only
     // error-code-labels. So for a start we go for cleartext output.
     $exitCode = exec($cmd, $output, $retval);
     // Variable $exitCode is the last line of $output if no error occures, on
     // error it is numeric. Try to handle various error conditions and
     // provide useful error reporting.
     if (is_numeric($exitCode) === true && $exitCode > 0) {
         if (is_array($output) === true) {
             $msg = join('\\n', $output);
         }
         throw new RuntimeException("Failed invoking ZendCodeAnalyzer, exitcode was [{$exitCode}], retval was [{$retval}], output was [{$msg}]");
     }
     if (is_array($output) === true) {
         foreach ($output as $finding) {
             // The first two lines of analyzer output contain
             // something like this:
             // > Zend Code Analyzer 1.2.2
             // > Analyzing <filename>...
             // So skip these...
             $res = preg_match("/^.+\\(line ([0-9]+)\\):(.+)\$/", $finding, $regs);
             if (empty($regs) === true || $res === false) {
                 continue;
             }
             $phpcsFile->addWarningOnLine(trim($regs[2]), $regs[1], 'ExternalTool');
         }
     }
     // Ignore the rest of the file.
     return $phpcsFile->numTokens + 1;
 }
开发者ID:thekabal,项目名称:tki,代码行数:51,代码来源:CodeAnalyzerSniff.php

示例5: process

 /**
  * Processes the tokens that this sniff is interested in.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
  * @param int                  $stackPtr  The position in the stack where
  *                                        the token was found.
  *
  * @return void
  * @throws PHP_CodeSniffer_Exception If jslint.js could not be run
  */
 public function process(File $phpcsFile, $stackPtr)
 {
     $lintPath = Config::getExecutablePath('gjslint');
     if ($lintPath === null) {
         return;
     }
     $fileName = $phpcsFile->getFilename();
     $cmd = "{$lintPath} --nosummary --notime --unix_mode \"{$fileName}\"";
     $msg = exec($cmd, $output, $retval);
     if (is_array($output) === false) {
         return;
     }
     foreach ($output as $finding) {
         $matches = array();
         $numMatches = preg_match('/^(.*):([0-9]+):\\(.*?([0-9]+)\\)(.*)$/', $finding, $matches);
         if ($numMatches === 0) {
             continue;
         }
         // Skip error codes we are ignoring.
         $code = $matches[3];
         if (in_array($code, $this->ignoreCodes) === true) {
             continue;
         }
         $line = (int) $matches[2];
         $error = trim($matches[4]);
         $message = 'gjslint says: (%s) %s';
         $data = array($code, $error);
         if (in_array($code, $this->errorCodes) === true) {
             $phpcsFile->addErrorOnLine($message, $line, 'ExternalToolError', $data);
         } else {
             $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool', $data);
         }
     }
     //end foreach
     // Ignore the rest of the file.
     return $phpcsFile->numTokens + 1;
 }
开发者ID:thekabal,项目名称:tki,代码行数:47,代码来源:ClosureLinterSniff.php


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