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


PHP PHP_CodeCoverage_Util::getLinesToBeIgnored方法代码示例

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


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

示例1: merge

 static function merge($project, $codeCoverageInformation)
 {
     $coverageDatabase = $project->getProperty('coverage.database');
     if (!$coverageDatabase) {
         throw new BuildException("Property coverage.database is not set - please include coverage-setup in your build file");
     }
     $database = new PhingFile($coverageDatabase);
     $props = new Properties();
     $props->load($database);
     $coverageTotal = $codeCoverageInformation;
     foreach ($coverageTotal as $filename => $data) {
         if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0) {
             $ignoreLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename);
         } else {
             // FIXME retrieve ignored lines for PHPUnit Version < 3.5.0
             $ignoreLines = array();
         }
         $lines = array();
         $filename = strtolower($filename);
         if ($props->getProperty($filename) != null) {
             foreach ($data as $_line => $_data) {
                 if (is_array($_data)) {
                     $count = count($_data);
                 } else {
                     if (isset($ignoreLines[$_line])) {
                         // line is marked as ignored
                         $count = 1;
                     } else {
                         if ($_data == -1) {
                             // not executed
                             $count = -1;
                         } else {
                             if ($_data == -2) {
                                 // dead code
                                 $count = -2;
                             }
                         }
                     }
                 }
                 $lines[$_line] = $count;
             }
             ksort($lines);
             $file = unserialize($props->getProperty($filename));
             $left = $file['coverage'];
             $coverageMerged = CoverageMerger::mergeCodeCoverage($left, $lines);
             $file['coverage'] = $coverageMerged;
             $props->setProperty($filename, serialize($file));
         }
     }
     $props->store($database);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:51,代码来源:CoverageMerger.php

示例2: process

 /**
  * @param  PHP_CodeCoverage $coverage
  * @param  string           $target
  * @param  string           $name
  * @return string
  */
 public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL)
 {
     $document = new DOMDocument('1.0', 'UTF-8');
     $document->formatOutput = TRUE;
     $root = $document->createElement('coverage');
     $root->setAttribute('generated', (int) $_SERVER['REQUEST_TIME']);
     $document->appendChild($root);
     $project = $document->createElement('project');
     $project->setAttribute('timestamp', (int) $_SERVER['REQUEST_TIME']);
     if (is_string($name)) {
         $project->setAttribute('name', $name);
     }
     $root->appendChild($project);
     $files = $coverage->getSummary();
     $packages = array();
     $projectStatistics = array('files' => 0, 'loc' => 0, 'ncloc' => 0, 'classes' => 0, 'methods' => 0, 'coveredMethods' => 0, 'conditionals' => 0, 'coveredConditionals' => 0, 'statements' => 0, 'coveredStatements' => 0);
     foreach ($files as $filename => $data) {
         $namespace = 'global';
         if (file_exists($filename)) {
             $fileStatistics = array('classes' => 0, 'methods' => 0, 'coveredMethods' => 0, 'conditionals' => 0, 'coveredConditionals' => 0, 'statements' => 0, 'coveredStatements' => 0);
             $file = $document->createElement('file');
             $file->setAttribute('name', $filename);
             $tokens = PHP_Token_Stream_CachingFactory::get($filename);
             $classesInFile = $tokens->getClasses();
             $linesOfCode = $tokens->getLinesOfCode();
             unset($tokens);
             $ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename);
             $lines = array();
             foreach ($classesInFile as $className => $_class) {
                 $classStatistics = array('methods' => 0, 'coveredMethods' => 0, 'conditionals' => 0, 'coveredConditionals' => 0, 'statements' => 0, 'coveredStatements' => 0);
                 foreach ($_class['methods'] as $methodName => $method) {
                     $classStatistics['methods']++;
                     $methodCount = 0;
                     $methodLines = 0;
                     $methodLinesCovered = 0;
                     for ($i = $method['startLine']; $i <= $method['endLine']; $i++) {
                         if (isset($ignoredLines[$i])) {
                             continue;
                         }
                         $add = TRUE;
                         $count = 0;
                         if (isset($files[$filename][$i])) {
                             if ($files[$filename][$i] != -2) {
                                 $classStatistics['statements']++;
                                 $methodLines++;
                             }
                             if (is_array($files[$filename][$i])) {
                                 $classStatistics['coveredStatements']++;
                                 $methodLinesCovered++;
                                 $count = count($files[$filename][$i]);
                             } else {
                                 if ($files[$filename][$i] == -2) {
                                     $add = FALSE;
                                 }
                             }
                         } else {
                             $add = FALSE;
                         }
                         $methodCount = max($methodCount, $count);
                         if ($add) {
                             $lines[$i] = array('count' => $count, 'type' => 'stmt');
                         }
                     }
                     if ($methodCount > 0) {
                         $classStatistics['coveredMethods']++;
                     }
                     $lines[$method['startLine']] = array('count' => $methodCount, 'crap' => PHP_CodeCoverage_Util::crap($method['ccn'], PHP_CodeCoverage_Util::percent($methodLinesCovered, $methodLines)), 'type' => 'method', 'name' => $methodName);
                 }
                 $package = PHP_CodeCoverage_Util::getPackageInformation($className, $_class['docblock']);
                 if (!empty($package['namespace'])) {
                     $namespace = $package['namespace'];
                 }
                 $class = $document->createElement('class');
                 $class->setAttribute('name', $className);
                 $class->setAttribute('namespace', $namespace);
                 if (!empty($package['fullPackage'])) {
                     $class->setAttribute('fullPackage', $package['fullPackage']);
                 }
                 if (!empty($package['category'])) {
                     $class->setAttribute('category', $package['category']);
                 }
                 if (!empty($package['package'])) {
                     $class->setAttribute('package', $package['package']);
                 }
                 if (!empty($package['subpackage'])) {
                     $class->setAttribute('subpackage', $package['subpackage']);
                 }
                 $file->appendChild($class);
                 $metrics = $document->createElement('metrics');
                 $metrics->setAttribute('methods', $classStatistics['methods']);
                 $metrics->setAttribute('coveredmethods', $classStatistics['coveredMethods']);
                 $metrics->setAttribute('conditionals', $classStatistics['conditionals']);
                 $metrics->setAttribute('coveredconditionals', $classStatistics['coveredConditionals']);
                 $metrics->setAttribute('statements', $classStatistics['statements']);
//.........这里部分代码省略.........
开发者ID:redlion09,项目名称:pcppi,代码行数:101,代码来源:Clover.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param  string                            $name
  * @param  PHP_CodeCoverage_Report_HTML_Node $parent
  * @param  array                             $executedLines
  * @param  boolean                           $yui
  * @param  boolean                           $highlight
  * @throws RuntimeException
  */
 public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, array $executedLines, $yui = TRUE, $highlight = FALSE)
 {
     parent::__construct($name, $parent);
     $path = $this->getPath();
     if (!file_exists($path)) {
         throw new RuntimeException(sprintf('Path "%s" does not exist.', $path));
     }
     $this->executedLines = $executedLines;
     $this->highlight = $highlight;
     $this->yui = $yui;
     $this->codeLines = $this->loadFile($path);
     $this->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($path);
     $this->calculateStatistics();
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:24,代码来源:File.php

示例4: __construct

 /**
  * Constructor.
  *
  * @param  string                       $name
  * @param  PHP_CodeCoverage_Report_Node $parent
  * @param  array                        $coverageData
  * @param  array                        $testData
  * @param  boolean                      $cacheTokens
  */
 public function __construct($name, PHP_CodeCoverage_Report_Node $parent, array $coverageData, array $testData, $cacheTokens)
 {
     if (!is_bool($cacheTokens)) {
         throw new InvalidArgumentException();
     }
     parent::__construct($name, $parent);
     $this->coverageData = $coverageData;
     $this->testData = $testData;
     $this->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($this->getPath(), $cacheTokens);
     $this->cacheTokens = $cacheTokens;
     $this->calculateStatistics();
 }
开发者ID:staabm,项目名称:redaxo,代码行数:21,代码来源:File.php

示例5: testGetLinesToBeIgnoredOneLineAnnotations

 /**
  * @covers PHP_CodeCoverage_Util::getLinesToBeIgnored
  */
 public function testGetLinesToBeIgnoredOneLineAnnotations()
 {
     $this->assertEquals(array(1 => TRUE, 2 => TRUE, 3 => TRUE, 4 => TRUE, 5 => TRUE, 6 => TRUE, 7 => TRUE, 8 => TRUE, 9 => TRUE, 10 => TRUE, 11 => TRUE, 12 => TRUE, 13 => TRUE, 14 => TRUE, 17 => TRUE, 19 => TRUE, 22 => TRUE, 23 => TRUE, 27 => TRUE, 28 => TRUE, 29 => TRUE, 30 => TRUE, 31 => TRUE, 32 => TRUE, 33 => TRUE), PHP_CodeCoverage_Util::getLinesToBeIgnored(TEST_FILES_PATH . 'source_with_oneline_annotations.php'));
 }
开发者ID:jeanCarloMachado,项目名称:challenges,代码行数:7,代码来源:UtilTest.php

示例6: testGetLinesToBeIgnored2

 /**
  * @covers PHP_CodeCoverage_Util::getLinesToBeIgnored
  */
 public function testGetLinesToBeIgnored2()
 {
     $this->assertEquals(array(), PHP_CodeCoverage_Util::getLinesToBeIgnored(TEST_FILES_PATH . 'source_without_ignore.php'));
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:7,代码来源:UtilTest.php

示例7: merge

 public static function merge($project, $codeCoverageInformation)
 {
     $props = self::_getDatabase($project);
     $coverageTotal = $codeCoverageInformation;
     foreach ($coverageTotal as $filename => $data) {
         $ignoreLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename);
         $lines = array();
         $filename = strtolower($filename);
         if ($props->getProperty($filename) != null) {
             foreach ($data as $_line => $_data) {
                 if (is_array($_data)) {
                     $count = count($_data);
                 } else {
                     if (isset($ignoreLines[$_line])) {
                         // line is marked as ignored
                         $count = 1;
                     } else {
                         if ($_data == -1) {
                             // not executed
                             $count = -1;
                         } else {
                             if ($_data == -2) {
                                 // dead code
                                 $count = -2;
                             }
                         }
                     }
                 }
                 $lines[$_line] = $count;
             }
             ksort($lines);
             $file = unserialize($props->getProperty($filename));
             $left = $file['coverage'];
             $coverageMerged = CoverageMerger::mergeCodeCoverage($left, $lines);
             $file['coverage'] = $coverageMerged;
             $props->setProperty($filename, serialize($file));
         }
     }
     $props->store();
 }
开发者ID:namesco,项目名称:phing,代码行数:40,代码来源:CoverageMerger.php

示例8: __construct

 /**
  * Constructor.
  *
  * @param  string                            $name
  * @param  PHP_CodeCoverage_Report_HTML_Node $parent
  * @param  array                             $coverageData
  * @param  array                             $testData
  * @param  boolean                           $cacheTokens
  * @param  boolean                           $yui
  * @param  boolean                           $highlight
  * @throws PHP_CodeCoverage_Exception
  */
 public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, array $coverageData, array $testData, $cacheTokens, $yui, $highlight)
 {
     parent::__construct($name, $parent);
     $path = $this->getPath();
     if (!file_exists($path)) {
         throw new PHP_CodeCoverage_Exception(sprintf('Path "%s" does not exist.', $path));
     }
     $this->coverageData = $coverageData;
     $this->testData = $testData;
     $this->cacheTokens = $cacheTokens;
     $this->highlight = $highlight;
     $this->yui = $yui;
     $this->codeLines = $this->loadFile($path);
     $this->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($path, $cacheTokens);
     $this->calculateStatistics();
 }
开发者ID:proofek,项目名称:php-code-coverage,代码行数:28,代码来源:File.php


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