Skip to content

Commit d10d9a5

Browse files
Increase PHPStan Rule Level to 6
1 parent 70c5a8c commit d10d9a5

10 files changed

Lines changed: 52 additions & 15 deletions

File tree

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 5
2+
level: 6
33

44
paths:
55
- src

src/Data/ProcessedClassType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ final class ProcessedClassType
3535
public int|string $crap;
3636
public readonly string $link;
3737

38+
/**
39+
* @param array<string, ProcessedMethodType> $methods
40+
*/
3841
public function __construct(
3942
string $className,
4043
string $namespace,
41-
/**
42-
* @var array<string, ProcessedMethodType>
43-
*/
4444
array $methods,
4545
int $startLine,
4646
int $executableLines,

src/Data/ProcessedCodeCoverageData.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ public function merge(self $newData): void
214214
*
215215
* During a merge, a higher number is better.
216216
*
217+
* @param array<int, null|list<TestIdType>> $data
218+
*
217219
* @return 1|2|3|4
218220
*/
219221
private function priorityForLine(array $data, int $line): int

src/Data/ProcessedTraitType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ final class ProcessedTraitType
3535
public int|string $crap;
3636
public readonly string $link;
3737

38+
/**
39+
* @param array<string, ProcessedMethodType> $methods
40+
*/
3841
public function __construct(
3942
string $traitName,
4043
string $namespace,
41-
/**
42-
* @var array<string, ProcessedMethodType>
43-
*/
4444
array $methods,
4545
int $startLine,
4646
int $executableLines,

src/Node/Builder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function build(ProcessedCodeCoverageData $codeCoverage, array $testResult
7373
}
7474

7575
/**
76+
* @param array<string, mixed> $items
7677
* @param array<string, TestType> $tests
7778
*/
7879
private function addItems(Directory $root, array $items, array $tests): void

src/Node/File.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use SebastianBergmann\CodeCoverage\CodeCoverage;
1616
use SebastianBergmann\CodeCoverage\Data\ProcessedBranchCoverageData;
1717
use SebastianBergmann\CodeCoverage\Data\ProcessedClassType;
18+
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionCoverageData;
1819
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionType;
1920
use SebastianBergmann\CodeCoverage\Data\ProcessedMethodType;
2021
use SebastianBergmann\CodeCoverage\Data\ProcessedPathCoverageData;
@@ -45,6 +46,10 @@ final class File extends AbstractNode
4546
* @var array<int, ?list<non-empty-string>>
4647
*/
4748
private array $lineCoverageData;
49+
50+
/**
51+
* @var array<string, ProcessedFunctionCoverageData>
52+
*/
4853
private array $functionCoverageData;
4954

5055
/**
@@ -82,17 +87,18 @@ final class File extends AbstractNode
8287
private ?int $numTestedFunctions = null;
8388

8489
/**
85-
* @var array<int, array|array{0: Class_, 1: string}|array{0: Function_|ProcessedFunctionType|ProcessedMethodType}|array{0: Trait_, 1: string}>
90+
* @var array<int, array<int, ProcessedClassType|ProcessedFunctionType|ProcessedMethodType|ProcessedTraitType>>
8691
*/
8792
private array $codeUnitsByLine = [];
8893

8994
/**
90-
* @param non-empty-string $sha1
91-
* @param array<int, ?list<non-empty-string>> $lineCoverageData
92-
* @param array<string, TestType> $testData
93-
* @param array<string, Class_> $classes
94-
* @param array<string, Trait_> $traits
95-
* @param array<string, Function_> $functions
95+
* @param non-empty-string $sha1
96+
* @param array<int, ?list<non-empty-string>> $lineCoverageData
97+
* @param array<string, ProcessedFunctionCoverageData> $functionCoverageData
98+
* @param array<string, TestType> $testData
99+
* @param array<string, Class_> $classes
100+
* @param array<string, Trait_> $traits
101+
* @param array<string, Function_> $functions
96102
*/
97103
public function __construct(string $name, AbstractNode $parent, string $sha1, array $lineCoverageData, array $functionCoverageData, array $testData, array $classes, array $traits, array $functions, LinesOfCode $linesOfCode)
98104
{
@@ -128,6 +134,9 @@ public function lineCoverageData(): array
128134
return $this->lineCoverageData;
129135
}
130136

137+
/**
138+
* @return array<string, ProcessedFunctionCoverageData>
139+
*/
131140
public function functionCoverageData(): array
132141
{
133142
return $this->functionCoverageData;

src/Report/Facade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public static function fromSerializedData(array $serializedCoverage): self
5656
);
5757
}
5858

59+
/**
60+
* @param array<string, array{size: string, status: string, time: float}> $testResults
61+
*/
5962
private function __construct(Directory $report, array $testResults)
6063
{
6164
$this->report = $report;

src/Report/Html/Renderer/File.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
120120
*
121121
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
122+
*
123+
* @phpstan-import-type TestType from \SebastianBergmann\CodeCoverage\CodeCoverage
122124
*/
123125
final class File extends Renderer
124126
{
@@ -800,7 +802,8 @@ private function renderBranchStructure(FileNode $node): string
800802
}
801803

802804
/**
803-
* @param list<string> $codeLines
805+
* @param list<string> $codeLines
806+
* @param array<string, TestType> $testData
804807
*/
805808
private function renderBranchLines(ProcessedBranchCoverageData $branch, array $codeLines, array $testData): string
806809
{
@@ -908,6 +911,7 @@ private function renderPathStructure(FileNode $node): string
908911
/**
909912
* @param array<int, ProcessedBranchCoverageData> $branches
910913
* @param list<string> $codeLines
914+
* @param array<string, TestType> $testData
911915
*/
912916
private function renderPathLines(ProcessedPathCoverageData $path, array $branches, array $codeLines, array $testData): string
913917
{
@@ -1119,6 +1123,9 @@ private function abbreviateMethodName(string $methodName): string
11191123
return $methodName;
11201124
}
11211125

1126+
/**
1127+
* @param TestType $testData
1128+
*/
11221129
private function createPopoverContentForTest(string $test, array $testData): string
11231130
{
11241131
$testCSS = '';

src/Report/Xml/Coverage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public function __construct(
2929
$this->line = $line;
3030
}
3131

32+
/**
33+
* @param list<string> $tests
34+
*/
3235
public function finalize(array $tests): void
3336
{
3437
$writer = $this->xmlWriter;

src/Test/Target/MapBuilder.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
/**
2626
* @phpstan-import-type TargetMap from Mapper
2727
* @phpstan-import-type TargetMapPart from Mapper
28+
* @phpstan-import-type ReverseLookup from Mapper
2829
*
2930
* @immutable
3031
*
@@ -169,6 +170,10 @@ public function build(Filter $filter, FileAnalyser $analyser): array
169170
];
170171
}
171172

173+
/**
174+
* @param array<non-empty-string, list<positive-int>> $sourceData
175+
* @param array<string, array<non-empty-string, array<int, positive-int>>> $data
176+
*/
172177
private function mergeLines(string $targetClass, array $sourceData, array &$data): void
173178
{
174179
/**
@@ -195,6 +200,13 @@ private function mergeLines(string $targetClass, array $sourceData, array &$data
195200
}
196201
}
197202

203+
/**
204+
* @param TargetMapPart $methods
205+
* @param ReverseLookup $reverseLookup
206+
*
207+
* @param-out TargetMapPart $methods
208+
* @param-out ReverseLookup $reverseLookup
209+
*/
198210
private function processMethods(Class_|Trait_ $classOrTrait, string $file, array &$methods, array &$reverseLookup): void
199211
{
200212
foreach ($classOrTrait->methods() as $method) {

0 commit comments

Comments
 (0)