|
13 | 13 | use function count; |
14 | 14 | use function range; |
15 | 15 | use SebastianBergmann\CodeCoverage\CrapIndex; |
16 | | -use SebastianBergmann\LinesOfCode\LinesOfCode; |
17 | 16 |
|
18 | 17 | /** |
19 | 18 | * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage |
@@ -81,7 +80,7 @@ final class File extends AbstractNode |
81 | 80 | private $functions = []; |
82 | 81 |
|
83 | 82 | /** |
84 | | - * @var LinesOfCode |
| 83 | + * @psalm-var array{linesOfCode: int, commentLinesOfCode: int, nonCommentLinesOfCode: int} |
85 | 84 | */ |
86 | 85 | private $linesOfCode; |
87 | 86 |
|
@@ -125,7 +124,10 @@ final class File extends AbstractNode |
125 | 124 | */ |
126 | 125 | private $codeUnitsByLine = []; |
127 | 126 |
|
128 | | - public function __construct(string $name, AbstractNode $parent, array $lineCoverageData, array $functionCoverageData, array $testData, array $classes, array $traits, array $functions, LinesOfCode $linesOfCode) |
| 127 | + /** |
| 128 | + * @psalm-param array{linesOfCode: int, commentLinesOfCode: int, nonCommentLinesOfCode: int} $linesOfCode |
| 129 | + */ |
| 130 | + public function __construct(string $name, AbstractNode $parent, array $lineCoverageData, array $functionCoverageData, array $testData, array $classes, array $traits, array $functions, array $linesOfCode) |
129 | 131 | { |
130 | 132 | parent::__construct($name, $parent); |
131 | 133 |
|
@@ -172,7 +174,10 @@ public function functions(): array |
172 | 174 | return $this->functions; |
173 | 175 | } |
174 | 176 |
|
175 | | - public function linesOfCode(): LinesOfCode |
| 177 | + /** |
| 178 | + * @psalm-return array{linesOfCode: int, commentLinesOfCode: int, nonCommentLinesOfCode: int} |
| 179 | + */ |
| 180 | + public function linesOfCode(): array |
176 | 181 | { |
177 | 182 | return $this->linesOfCode; |
178 | 183 | } |
@@ -330,15 +335,15 @@ public function numberOfTestedFunctions(): int |
330 | 335 |
|
331 | 336 | private function calculateStatistics(array $classes, array $traits, array $functions): void |
332 | 337 | { |
333 | | - foreach (range(1, $this->linesOfCode->linesOfCode()) as $lineNumber) { |
| 338 | + foreach (range(1, $this->linesOfCode['linesOfCode']) as $lineNumber) { |
334 | 339 | $this->codeUnitsByLine[$lineNumber] = []; |
335 | 340 | } |
336 | 341 |
|
337 | 342 | $this->processClasses($classes); |
338 | 343 | $this->processTraits($traits); |
339 | 344 | $this->processFunctions($functions); |
340 | 345 |
|
341 | | - foreach (range(1, $this->linesOfCode->linesOfCode()) as $lineNumber) { |
| 346 | + foreach (range(1, $this->linesOfCode['linesOfCode']) as $lineNumber) { |
342 | 347 | if (isset($this->lineCoverageData[$lineNumber])) { |
343 | 348 | foreach ($this->codeUnitsByLine[$lineNumber] as &$codeUnit) { |
344 | 349 | $codeUnit['executableLines']++; |
|
0 commit comments