From 5e5e8cb3a2cd34795e2228aadf7cebd9f59da03c Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Tue, 10 Dec 2024 16:40:52 +0100 Subject: [PATCH] Narrow types --- src/Data/ProcessedCodeCoverageData.php | 2 ++ src/Node/File.php | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Data/ProcessedCodeCoverageData.php b/src/Data/ProcessedCodeCoverageData.php index db01aecb..57ccbb16 100644 --- a/src/Data/ProcessedCodeCoverageData.php +++ b/src/Data/ProcessedCodeCoverageData.php @@ -219,6 +219,8 @@ public function merge(self $newData): void * 4 = the line has been tested * * During a merge, a higher number is better. + * + * @return 1|2|3|4 */ private function priorityForLine(array $data, int $line): int { diff --git a/src/Node/File.php b/src/Node/File.php index e7cbb5b2..df45d530 100644 --- a/src/Node/File.php +++ b/src/Node/File.php @@ -12,6 +12,7 @@ use function array_filter; use function count; use function range; +use SebastianBergmann\CodeCoverage\CodeCoverage; use SebastianBergmann\CodeCoverage\StaticAnalysis\Class_; use SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser; use SebastianBergmann\CodeCoverage\StaticAnalysis\Function_; @@ -22,6 +23,7 @@ /** * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage * + * @phpstan-import-type TestType from CodeCoverage * @phpstan-import-type LinesType from FileAnalyser * * @phpstan-type ProcessedFunctionType array{ @@ -98,6 +100,10 @@ final class File extends AbstractNode */ private array $lineCoverageData; private array $functionCoverageData; + + /** + * @var array + */ private readonly array $testData; private int $numExecutableLines = 0; private int $numExecutedLines = 0; @@ -136,6 +142,7 @@ final class File extends AbstractNode /** * @param array> $lineCoverageData + * @param array $testData * @param array $classes * @param array $traits * @param array $functions @@ -170,6 +177,9 @@ public function functionCoverageData(): array return $this->functionCoverageData; } + /** + * @return array + */ public function testData(): array { return $this->testData;