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


PHP Result::addFile方法代码示例

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


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

示例1: run

 /**
  * PHPca's main method. Returns a result object holding
  * error and warning messages for all the files that have been analyzed.
  *
  * @param string $pathToPhpExecutable path to PHP executable for lint check
  * @param string $fileOrDirectory     path to file or directory to check
  * @return object
  */
 public function run($pathToPhpExecutable, $fileOrDirectory, Configuration $configuration = null)
 {
     if ($pathToPhpExecutable == '') {
         throw new Exception('No path to PHP executable specified');
     }
     if ($fileOrDirectory == '') {
         throw new Exception('No file or directory to analyze');
     }
     if (!is_null($configuration)) {
         $this->configuration = $configuration;
     }
     // Define our own additionl T_* token constants
     Constants::init();
     // Set up the lint checker and make sure that given path points to a PHP binary
     $linter = new Linter($pathToPhpExecutable);
     // Create result object that collects the error and warning messages
     $this->result = new Result();
     // Create a list of all rules to enforce
     $this->rules = $this->loadRules($this->configuration->getRules());
     // List all PHP files in given path
     $phpFiles = $this->listFiles($fileOrDirectory, $this->configuration->getExtensions());
     if (sizeof($phpFiles) == 0) {
         throw new Exception('No PHP files to analyze');
     }
     $this->numberOfFiles = sizeof($phpFiles);
     foreach ($phpFiles as $phpFile) {
         // Remember that we have processed this file,
         // even if it generates no message at all.
         $this->result->addFile($phpFile);
         if ($this->isSkipped($phpFile)) {
             $this->result->addMessage(new Skipped($phpFile, 'Skipped'));
         } else {
             if ($linter->runLintCheck($phpFile)) {
                 $file = Tokenizer::tokenize($phpFile, file_get_contents($phpFile));
                 $this->result->addNamespaces($phpFile, $file->getNamespaces());
                 $this->result->addClasses($phpFile, $file->getClasses());
                 $this->result->addFunctions($phpFile, $file->getFunctions());
                 $this->enforceRules($phpFile, $file);
             } else {
                 $this->result->addMessage(new LintError($phpFile, $linter->getErrorMessages()));
             }
         }
         // Notify the progress printer that we have analyzed a file
         if (is_object($this->progressPrinter)) {
             $this->progressPrinter->showProgress($phpFile, $this->result, $this);
         }
         unset($phpFile);
     }
     // Return the result object containing all error and warning messages
     return $this->result;
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:59,代码来源:Application.php

示例2: testGetNumberOfRuleErrors

 /**
  * @covers spriebsch\PHPca\Result::addMessage
  * @covers spriebsch\PHPca\Result::getNumberOfRuleErrors
  */
 public function testGetNumberOfRuleErrors()
 {
     $result = new Result();
     $result->addFile('testfile');
     $error = new RuleError('testfile', 'error message');
     $result->addMessage($error);
     $this->assertEquals(1, $result->getNumberOfRuleErrors('testfile'));
 }
开发者ID:spriebsch,项目名称:phpca,代码行数:12,代码来源:ResultTest.php


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