Skip to content

Commit 44e31d9

Browse files
Add type declarations
1 parent cd84543 commit 44e31d9

File tree

4 files changed

+9
-56
lines changed

4 files changed

+9
-56
lines changed

src/CodeCoverage.php

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,15 @@ final class CodeCoverage
4747

4848
private Filter $filter;
4949

50-
/**
51-
* @var Wizard
52-
*/
53-
private $wizard;
50+
private Wizard $wizard;
5451

5552
private bool $checkForUnintentionallyCoveredCode = false;
5653

5754
private bool $includeUncoveredFiles = true;
5855

5956
private bool $ignoreDeprecatedCode = false;
6057

61-
/**
62-
* @var PhptTestCase|string|TestCase
63-
*/
64-
private $currentId;
58+
private PhptTestCase|string|TestCase|null $currentId;
6559

6660
private ProcessedCodeCoverageData $data;
6761

@@ -150,12 +144,7 @@ public function setTests(array $tests): void
150144
$this->tests = $tests;
151145
}
152146

153-
/**
154-
* Start collection of code coverage information.
155-
*
156-
* @param PhptTestCase|string|TestCase $id
157-
*/
158-
public function start($id, bool $clear = false): void
147+
public function start(PhptTestCase|string|TestCase $id, bool $clear = false): void
159148
{
160149
if ($clear) {
161150
$this->clear();
@@ -166,12 +155,7 @@ public function start($id, bool $clear = false): void
166155
$this->driver->start();
167156
}
168157

169-
/**
170-
* Stop collection of code coverage information.
171-
*
172-
* @param array|false $linesToBeCovered
173-
*/
174-
public function stop(bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = []): RawCodeCoverageData
158+
public function stop(bool $append = true, array|false $linesToBeCovered = [], array $linesToBeUsed = []): RawCodeCoverageData
175159
{
176160
if (!is_array($linesToBeCovered) && $linesToBeCovered !== false) {
177161
throw new InvalidArgumentException(
@@ -188,16 +172,11 @@ public function stop(bool $append = true, $linesToBeCovered = [], array $linesTo
188172
}
189173

190174
/**
191-
* Appends code coverage data.
192-
*
193-
* @param PhptTestCase|string|TestCase $id
194-
* @param array|false $linesToBeCovered
195-
*
196175
* @throws ReflectionException
197176
* @throws TestIdMissingException
198177
* @throws UnintentionallyCoveredCodeException
199178
*/
200-
public function append(RawCodeCoverageData $rawData, $id = null, bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = []): void
179+
public function append(RawCodeCoverageData $rawData, PhptTestCase|string|TestCase|null $id = null, bool $append = true, array|false $linesToBeCovered = [], array $linesToBeUsed = []): void
201180
{
202181
if ($id === null) {
203182
$id = $this->currentId;
@@ -367,14 +346,10 @@ public function detectsDeadCode(): bool
367346
}
368347

369348
/**
370-
* Applies the @covers annotation filtering.
371-
*
372-
* @param array|false $linesToBeCovered
373-
*
374349
* @throws ReflectionException
375350
* @throws UnintentionallyCoveredCodeException
376351
*/
377-
private function applyCoversAnnotationFilter(RawCodeCoverageData $rawData, $linesToBeCovered, array $linesToBeUsed): void
352+
private function applyCoversAnnotationFilter(RawCodeCoverageData $rawData, array|false $linesToBeCovered, array $linesToBeUsed): void
378353
{
379354
if ($linesToBeCovered === false) {
380355
$rawData->clear();

src/Report/Text.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ private function printCoverageCounts(int $numberOfCoveredElements, int $totalNum
317317
sprintf($format, $totalNumberOfElements) . ')';
318318
}
319319

320-
/**
321-
* @param false|string $string
322-
*/
323-
private function format(string $color, int $padding, $string): string
320+
private function format(string $color, int $padding, string|false $string): string
324321
{
325322
$reset = $color ? self::COLOR_RESET : '';
326323

src/StaticAnalysis/Cache.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ protected function has(string $filename, string $key): bool
5050

5151
/**
5252
* @psalm-param list<class-string> $allowedClasses
53-
*
54-
* @return mixed
5553
*/
56-
protected function read(string $filename, string $key, array $allowedClasses = [])
54+
protected function read(string $filename, string $key, array $allowedClasses = []): mixed
5755
{
5856
$options = ['allowed_classes' => false];
5957

@@ -69,10 +67,7 @@ protected function read(string $filename, string $key, array $allowedClasses = [
6967
);
7068
}
7169

72-
/**
73-
* @param mixed $data
74-
*/
75-
protected function write(string $filename, string $key, $data): void
70+
protected function write(string $filename, string $key, mixed $data): void
7671
{
7772
file_put_contents(
7873
$this->cacheFile($filename, $key),

tests/tests/CodeCoverageTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,6 @@ protected function setUp(): void
3939
);
4040
}
4141

42-
public function testCannotStopWithInvalidSecondArgument(): void
43-
{
44-
$this->expectException(Exception::class);
45-
46-
$this->coverage->stop(true, null);
47-
}
48-
49-
public function testCannotAppendWithInvalidArgument(): void
50-
{
51-
$this->expectException(Exception::class);
52-
53-
$this->coverage->append(RawCodeCoverageData::fromXdebugWithoutPathCoverage([]), null);
54-
}
55-
5642
public function testCollect(): void
5743
{
5844
$coverage = $this->getLineCoverageForBankAccount();

0 commit comments

Comments
 (0)