Skip to content

Commit 0e0fe59

Browse files
committed
fix
1 parent 062c1d4 commit 0e0fe59

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/Node/File.php

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

12+
use SebastianBergmann\CodeCoverage\Data\ProcessedBranchCoverageData;
13+
use SebastianBergmann\CodeCoverage\Data\ProcessedPathCoverageData;
1214
use function array_filter;
1315
use function count;
1416
use function range;
@@ -664,33 +666,33 @@ private function newMethod(string $className, Method $method, string $link): arr
664666

665667
$key = $className . '->' . $method->name();
666668

667-
if (isset($this->functionCoverageData[$key]['branches'])) {
669+
if (isset($this->functionCoverageData[$key])) {
668670
$methodData['executableBranches'] = count(
669-
$this->functionCoverageData[$key]['branches'],
671+
$this->functionCoverageData[$key]->branches,
670672
);
671673

672674
$methodData['executedBranches'] = count(
673675
array_filter(
674-
$this->functionCoverageData[$key]['branches'],
675-
static function (array $branch)
676+
$this->functionCoverageData[$key]->branches,
677+
static function (ProcessedBranchCoverageData $branch)
676678
{
677-
return (bool) $branch['hit'];
679+
return (bool) $branch->hit;
678680
},
679681
),
680682
);
681683
}
682684

683-
if (isset($this->functionCoverageData[$key]['paths'])) {
685+
if (isset($this->functionCoverageData[$key])) {
684686
$methodData['executablePaths'] = count(
685-
$this->functionCoverageData[$key]['paths'],
687+
$this->functionCoverageData[$key]->paths,
686688
);
687689

688690
$methodData['executedPaths'] = count(
689691
array_filter(
690-
$this->functionCoverageData[$key]['paths'],
691-
static function (array $path)
692+
$this->functionCoverageData[$key]->paths,
693+
static function (ProcessedPathCoverageData $path)
692694
{
693-
return (bool) $path['hit'];
695+
return (bool) $path->hit;
694696
},
695697
),
696698
);

tests/tests/Data/ProcessedCodeCoverageDataTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public function testMergeDoesNotCrashWhenFileContentsHaveChanged(): void
167167

168168
$coverage->merge($newCoverage);
169169

170+
$this->assertIsArray($newCoverage->functionCoverage()['/some/path/SomeClass.php']);
170171
$this->assertArrayHasKey('SomeClass->secondFunction', $newCoverage->functionCoverage()['/some/path/SomeClass.php']);
171172
}
172173
}

0 commit comments

Comments
 (0)