diff --git a/phpstan.neon b/phpstan.neon index 7d7f95975..a95f15d28 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 5 + level: 6 paths: - src - tests/tests diff --git a/src/Data/ProcessedCodeCoverageData.php b/src/Data/ProcessedCodeCoverageData.php index 57ccbb166..70f2d811c 100644 --- a/src/Data/ProcessedCodeCoverageData.php +++ b/src/Data/ProcessedCodeCoverageData.php @@ -41,7 +41,10 @@ * }>, * hit: list * } - * @phpstan-type FunctionCoverageType array> + * @phpstan-type FunctionCoverageForFileType array + * @phpstan-type FunctionCoverageType array + * @phpstan-type LineCoverageForFileType array> + * @phpstan-type LineCoverageType array */ final class ProcessedCodeCoverageData { @@ -49,7 +52,7 @@ final class ProcessedCodeCoverageData * Line coverage data. * An array of filenames, each having an array of linenumbers, each executable line having an array of testcase ids. * - * @var array>> + * @var LineCoverageType */ private array $lineCoverage = []; @@ -112,11 +115,17 @@ public function markCodeAsExecutedByTestCase(string $testCaseId, RawCodeCoverage } } + /** + * @param LineCoverageType $lineCoverage + */ public function setLineCoverage(array $lineCoverage): void { $this->lineCoverage = $lineCoverage; } + /** + * @return LineCoverageType + */ public function lineCoverage(): array { ksort($this->lineCoverage); @@ -124,11 +133,17 @@ public function lineCoverage(): array return $this->lineCoverage; } + /** + * @param FunctionCoverageType $functionCoverage + */ public function setFunctionCoverage(array $functionCoverage): void { $this->functionCoverage = $functionCoverage; } + /** + * @return FunctionCoverageType + */ public function functionCoverage(): array { ksort($this->functionCoverage); @@ -136,6 +151,9 @@ public function functionCoverage(): array return $this->functionCoverage; } + /** + * @return list + */ public function coveredFiles(): array { ksort($this->lineCoverage); @@ -220,6 +238,8 @@ public function merge(self $newData): void * * During a merge, a higher number is better. * + * @param LineCoverageForFileType $data + * * @return 1|2|3|4 */ private function priorityForLine(array $data, int $line): int diff --git a/src/Node/Builder.php b/src/Node/Builder.php index e6b83f999..90454dec8 100644 --- a/src/Node/Builder.php +++ b/src/Node/Builder.php @@ -29,6 +29,8 @@ * @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 FunctionCoverageForFileType from ProcessedCodeCoverageData + * @phpstan-import-type LineCoverageForFileType from ProcessedCodeCoverageData */ final readonly class Builder { @@ -132,7 +134,7 @@ private function addItems(Directory $root, array $items, array $tests): void * ) * * - * @return array, functionCoverage: array>}>> + * @return array */ private function buildDirectoryStructure(ProcessedCodeCoverageData $data): array { diff --git a/src/Report/Html/Renderer/File.php b/src/Report/Html/Renderer/File.php index 09dbe31fe..b1c3f7e97 100644 --- a/src/Report/Html/Renderer/File.php +++ b/src/Report/Html/Renderer/File.php @@ -102,6 +102,7 @@ use function str_replace; use function token_get_all; use function trim; +use SebastianBergmann\CodeCoverage\CodeCoverage; use SebastianBergmann\CodeCoverage\FileCouldNotBeWrittenException; use SebastianBergmann\CodeCoverage\Node\File as FileNode; use SebastianBergmann\CodeCoverage\Util\Percentage; @@ -113,6 +114,7 @@ * @phpstan-import-type ProcessedTraitType from FileNode * @phpstan-import-type ProcessedMethodType from FileNode * @phpstan-import-type ProcessedFunctionType from FileNode + * @phpstan-import-type TestType from CodeCoverage * * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage */ @@ -906,7 +908,8 @@ private function renderPathStructure(FileNode $node): string } /** - * @param list $codeLines + * @param list $codeLines + * @param array $testData */ private function renderPathLines(array $path, array $branches, array $codeLines, array $testData): string { @@ -1118,6 +1121,9 @@ private function abbreviateMethodName(string $methodName): string return $methodName; } + /** + * @param TestType $testData + */ private function createPopoverContentForTest(string $test, array $testData): string { $testCSS = ''; diff --git a/src/Target/MapBuilder.php b/src/Target/MapBuilder.php index 11a8088ff..cfda06293 100644 --- a/src/Target/MapBuilder.php +++ b/src/Target/MapBuilder.php @@ -206,6 +206,10 @@ public function build(Filter $filter, FileAnalyser $analyser): array ]; } + /** + * @param TargetMapPart $methods + * @param array $reverseLookup + */ private function processMethods(Class_|Trait_ $classOrTrait, string $file, array &$methods, array &$reverseLookup): void { foreach ($classOrTrait->methods() as $method) { diff --git a/tests/tests/Target/MapBuilderTest.php b/tests/tests/Target/MapBuilderTest.php index dbdaef30d..de1612653 100644 --- a/tests/tests/Target/MapBuilderTest.php +++ b/tests/tests/Target/MapBuilderTest.php @@ -417,6 +417,10 @@ public static function provider(): array ]; } + /** + * @param TargetMap $expected + * @param non-empty-list $files + */ #[DataProvider('provider')] public function testBuildsMap(array $expected, array $files): void {