Skip to content

Commit 3a34631

Browse files
Narrow types
1 parent 6c8fd83 commit 3a34631

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

src/CodeCoverage.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838
/**
3939
* Provides collection functionality for PHP code coverage information.
4040
*
41-
* @phpstan-type TestType array{
42-
* size: string,
43-
* status: string,
44-
* }
41+
* @phpstan-type TestType array{size: string, status: string}
42+
* @phpstan-type TargetedLines array<non-empty-string, list<positive-int>>
4543
*/
4644
final class CodeCoverage
4745
{
@@ -374,6 +372,9 @@ public function validate(TargetCollection $targets): ValidationResult
374372
}
375373

376374
/**
375+
* @param false|TargetedLines $linesToBeCovered
376+
* @param TargetedLines $linesToBeUsed
377+
*
377378
* @throws ReflectionException
378379
* @throws UnintentionallyCoveredCodeException
379380
*/
@@ -478,6 +479,9 @@ private function addUncoveredFilesFromFilter(): void
478479
}
479480

480481
/**
482+
* @param TargetedLines $linesToBeCovered
483+
* @param TargetedLines $linesToBeUsed
484+
*
481485
* @throws ReflectionException
482486
* @throws UnintentionallyCoveredCodeException
483487
*/
@@ -507,6 +511,12 @@ private function performUnintentionallyCoveredCodeCheck(RawCodeCoverageData $dat
507511
}
508512
}
509513

514+
/**
515+
* @param TargetedLines $linesToBeCovered
516+
* @param TargetedLines $linesToBeUsed
517+
*
518+
* @return TargetedLines
519+
*/
510520
private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed): array
511521
{
512522
$allowedLines = [];

src/Data/RawCodeCoverageData.php

+3
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ private function skipEmptyLines(): void
261261
}
262262
}
263263

264+
/**
265+
* @return array<int>
266+
*/
264267
private function getEmptyLinesForFile(string $filename): array
265268
{
266269
if (!isset(self::$emptyLineCache[$filename])) {

src/Node/AbstractNode.php

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ abstract class AbstractNode implements Countable
2929
{
3030
private readonly string $name;
3131
private string $pathAsString;
32+
33+
/**
34+
* @var non-empty-list<self>
35+
*/
3236
private array $pathAsArray;
3337
private readonly ?AbstractNode $parent;
3438
private string $id;
@@ -61,6 +65,9 @@ public function pathAsString(): string
6165
return $this->pathAsString;
6266
}
6367

68+
/**
69+
* @return non-empty-list<self>
70+
*/
6471
public function pathAsArray(): array
6572
{
6673
return $this->pathAsArray;

src/Node/Iterator.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use RecursiveIterator;
1515

1616
/**
17+
* @template-implements RecursiveIterator<int, AbstractNode>
18+
*
1719
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
1820
*/
1921
final class Iterator implements RecursiveIterator

0 commit comments

Comments
 (0)