Skip to content

Commit a3216ce

Browse files
committed
fix
1 parent 416967d commit a3216ce

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

src/Data/ProcessedBranchCoverageData.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @phpstan-import-type TestIdType from ProcessedCodeCoverageData
1818
* @phpstan-import-type XdebugBranchCoverageType from XdebugDriver
1919
*/
20-
final readonly class ProcessedBranchCoverageData
20+
final class ProcessedBranchCoverageData
2121
{
2222
/**
2323
* @param XdebugBranchCoverageType $xdebugCoverageData
@@ -36,19 +36,20 @@ public static function fromXdebugCoverage(array $xdebugCoverageData): self
3636
}
3737

3838
public function __construct(
39-
public int $op_start,
40-
public int $op_end,
41-
public int $line_start,
42-
public int $line_end,
39+
readonly public int $op_start,
40+
readonly public int $op_end,
41+
readonly public int $line_start,
42+
readonly public int $line_end,
4343
/** @var list<TestIdType> */
4444
public array $hit,
4545
/** @var array<int, int> */
46-
public array $out,
46+
readonly public array $out,
4747
/** @var array<int, int> */
48-
public array $out_hit,
48+
readonly public array $out_hit,
4949
) {
5050
}
5151

52+
#[\NoDiscard]
5253
public function merge(self $data): self
5354
{
5455
return new self(
@@ -65,19 +66,8 @@ public function merge(self $data): self
6566
/**
6667
* @param TestIdType $testCaseId
6768
*/
68-
public function recordHit(string $testCaseId): self
69+
public function recordHit(string $testCaseId): void
6970
{
70-
$hit = $this->hit;
71-
$hit[] = $testCaseId;
72-
73-
return new self(
74-
$this->op_start,
75-
$this->op_end,
76-
$this->line_start,
77-
$this->line_end,
78-
$hit,
79-
$this->out,
80-
$this->out_hit,
81-
);
71+
$this->hit[] = $testCaseId;
8272
}
8373
}

src/Data/ProcessedFunctionCoverageData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @phpstan-import-type TestIdType from ProcessedCodeCoverageData
1616
* @phpstan-import-type XdebugFunctionCoverageType from XdebugDriver
1717
*/
18-
final class ProcessedFunctionCoverageData
18+
final readonly class ProcessedFunctionCoverageData
1919
{
2020
/**
2121
* @param XdebugFunctionCoverageType $xdebugCoverageData

src/Data/ProcessedPathCoverageData.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
namespace SebastianBergmann\CodeCoverage\Data;
1111

12+
use NoDiscard;
1213
use function array_merge;
1314
use function array_unique;
1415
use SebastianBergmann\CodeCoverage\Driver\XdebugDriver;
@@ -17,7 +18,7 @@
1718
* @phpstan-import-type TestIdType from ProcessedCodeCoverageData
1819
* @phpstan-import-type XdebugPathCoverageType from XdebugDriver
1920
*/
20-
final readonly class ProcessedPathCoverageData
21+
final class ProcessedPathCoverageData
2122
{
2223
/**
2324
* @param XdebugPathCoverageType $xdebugCoverageData
@@ -32,12 +33,13 @@ public static function fromXdebugCoverage(array $xdebugCoverageData): self
3233

3334
public function __construct(
3435
/** @var array<int, int> */
35-
public array $path,
36+
public readonly array $path,
3637
/** @var list<TestIdType> */
3738
public array $hit,
3839
) {
3940
}
4041

42+
#[\NoDiscard]
4143
public function merge(self $data): self
4244
{
4345
return new self(
@@ -49,14 +51,8 @@ public function merge(self $data): self
4951
/**
5052
* @param TestIdType $testCaseId
5153
*/
52-
public function recordHit(string $testCaseId): self
54+
public function recordHit(string $testCaseId): void
5355
{
54-
$hit = $this->hit;
55-
$hit[] = $testCaseId;
56-
57-
return new self(
58-
$this->path,
59-
$hit,
60-
);
56+
$this->hit[] = $testCaseId;
6157
}
6258
}

0 commit comments

Comments
 (0)