|
11 | 11 |
|
12 | 12 | use function array_filter; |
13 | 13 | use function count; |
14 | | -use function range; |
15 | 14 | use SebastianBergmann\CodeCoverage\CodeCoverage; |
16 | 15 | use SebastianBergmann\CodeCoverage\StaticAnalysis\AnalysisResult; |
17 | 16 | use SebastianBergmann\CodeCoverage\StaticAnalysis\Class_; |
@@ -372,15 +371,15 @@ public function numberOfTestedFunctions(): int |
372 | 371 | */ |
373 | 372 | private function calculateStatistics(array $classes, array $traits, array $functions): void |
374 | 373 | { |
375 | | - foreach (range(1, $this->linesOfCode->linesOfCode()) as $lineNumber) { |
| 374 | + for ($lineNumber = 1; $lineNumber <= $this->linesOfCode->linesOfCode(); $lineNumber++) { |
376 | 375 | $this->codeUnitsByLine[$lineNumber] = []; |
377 | 376 | } |
378 | 377 |
|
379 | 378 | $this->processClasses($classes); |
380 | 379 | $this->processTraits($traits); |
381 | 380 | $this->processFunctions($functions); |
382 | 381 |
|
383 | | - foreach (range(1, $this->linesOfCode->linesOfCode()) as $lineNumber) { |
| 382 | + for ($lineNumber = 1; $lineNumber <= $this->linesOfCode->linesOfCode(); $lineNumber++) { |
384 | 383 | if (isset($this->lineCoverageData[$lineNumber])) { |
385 | 384 | foreach ($this->codeUnitsByLine[$lineNumber] as &$codeUnit) { |
386 | 385 | $codeUnit['executableLines']++; |
@@ -511,7 +510,7 @@ private function processClasses(array $classes): void |
511 | 510 | $this->numExecutablePaths += $methodData['executablePaths']; |
512 | 511 | $this->numExecutedPaths += $methodData['executedPaths']; |
513 | 512 |
|
514 | | - foreach (range($method->startLine(), $method->endLine()) as $lineNumber) { |
| 513 | + for ($lineNumber = $method->startLine(); $lineNumber <= $method->endLine(); $lineNumber++) { |
515 | 514 | $this->codeUnitsByLine[$lineNumber] = [ |
516 | 515 | &$this->classes[$className], |
517 | 516 | &$this->classes[$className]['methods'][$methodName], |
@@ -560,7 +559,7 @@ private function processTraits(array $traits): void |
560 | 559 | $this->numExecutablePaths += $methodData['executablePaths']; |
561 | 560 | $this->numExecutedPaths += $methodData['executedPaths']; |
562 | 561 |
|
563 | | - foreach (range($method->startLine(), $method->endLine()) as $lineNumber) { |
| 562 | + for ($lineNumber = $method->startLine(); $lineNumber <= $method->endLine(); $lineNumber++) { |
564 | 563 | $this->codeUnitsByLine[$lineNumber] = [ |
565 | 564 | &$this->traits[$traitName], |
566 | 565 | &$this->traits[$traitName]['methods'][$methodName], |
@@ -596,7 +595,7 @@ private function processFunctions(array $functions): void |
596 | 595 | 'link' => $link . $function->startLine(), |
597 | 596 | ]; |
598 | 597 |
|
599 | | - foreach (range($function->startLine(), $function->endLine()) as $lineNumber) { |
| 598 | + for ($lineNumber = $function->startLine(); $lineNumber <= $function->endLine(); $lineNumber++) { |
600 | 599 | $this->codeUnitsByLine[$lineNumber] = [&$this->functions[$functionName]]; |
601 | 600 | } |
602 | 601 |
|
|
0 commit comments