1212use function array_filter ;
1313use function count ;
1414use function range ;
15+ use SebastianBergmann \CodeCoverage \StaticAnalysis \LinesOfCode ;
1516
1617/**
1718 * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
2021 * @phpstan-import-type CodeUnitMethodType from \SebastianBergmann\CodeCoverage\StaticAnalysis\CodeUnitFindingVisitor
2122 * @phpstan-import-type CodeUnitClassType from \SebastianBergmann\CodeCoverage\StaticAnalysis\CodeUnitFindingVisitor
2223 * @phpstan-import-type CodeUnitTraitType from \SebastianBergmann\CodeCoverage\StaticAnalysis\CodeUnitFindingVisitor
23- * @phpstan-import-type LinesOfCodeType from \SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser
2424 * @phpstan-import-type LinesType from \SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser
2525 *
2626 * @phpstan-type ProcessedFunctionType = array{
@@ -119,11 +119,7 @@ final class File extends AbstractNode
119119 * @var array<string, ProcessedFunctionType>
120120 */
121121 private array $ functions = [];
122-
123- /**
124- * @var LinesOfCodeType
125- */
126- private readonly array $ linesOfCode ;
122+ private readonly LinesOfCode $ linesOfCode ;
127123 private ?int $ numClasses = null ;
128124 private int $ numTestedClasses = 0 ;
129125 private ?int $ numTraits = null ;
@@ -142,9 +138,8 @@ final class File extends AbstractNode
142138 * @param array<string, CodeUnitClassType> $classes
143139 * @param array<string, CodeUnitTraitType> $traits
144140 * @param array<string, CodeUnitFunctionType> $functions
145- * @param LinesOfCodeType $linesOfCode
146141 */
147- public function __construct (string $ name , AbstractNode $ parent , array $ lineCoverageData , array $ functionCoverageData , array $ testData , array $ classes , array $ traits , array $ functions , array $ linesOfCode )
142+ public function __construct (string $ name , AbstractNode $ parent , array $ lineCoverageData , array $ functionCoverageData , array $ testData , array $ classes , array $ traits , array $ functions , LinesOfCode $ linesOfCode )
148143 {
149144 parent ::__construct ($ name , $ parent );
150145
@@ -203,7 +198,7 @@ public function functions(): array
203198 return $ this ->functions ;
204199 }
205200
206- public function linesOfCode (): array
201+ public function linesOfCode (): LinesOfCode
207202 {
208203 return $ this ->linesOfCode ;
209204 }
@@ -366,15 +361,15 @@ public function numberOfTestedFunctions(): int
366361 */
367362 private function calculateStatistics (array $ classes , array $ traits , array $ functions ): void
368363 {
369- foreach (range (1 , $ this ->linesOfCode [ ' linesOfCode ' ] ) as $ lineNumber ) {
364+ foreach (range (1 , $ this ->linesOfCode -> linesOfCode () ) as $ lineNumber ) {
370365 $ this ->codeUnitsByLine [$ lineNumber ] = [];
371366 }
372367
373368 $ this ->processClasses ($ classes );
374369 $ this ->processTraits ($ traits );
375370 $ this ->processFunctions ($ functions );
376371
377- foreach (range (1 , $ this ->linesOfCode [ ' linesOfCode ' ] ) as $ lineNumber ) {
372+ foreach (range (1 , $ this ->linesOfCode -> linesOfCode () ) as $ lineNumber ) {
378373 if (isset ($ this ->lineCoverageData [$ lineNumber ])) {
379374 foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
380375 $ codeUnit ['executableLines ' ]++;
0 commit comments