Skip to content

Commit 069b410

Browse files
Limit information about unintentionally covered units of code to class names and function names
1 parent ed344b8 commit 069b410

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

.psalm/baseline.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<files psalm-version="4.x-dev@">
33
<file src="src/CodeCoverage.php">
44
<ArgumentTypeCoercion occurrences="1">
5-
<code>$unit[0]</code>
5+
<code>$tmp[0]</code>
66
</ArgumentTypeCoercion>
77
<RedundantCondition occurrences="1">
88
<code>is_array($linesToBeCovered)</code>

src/CodeCoverage.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use function array_keys;
1616
use function array_merge;
1717
use function array_unique;
18-
use function array_values;
1918
use function count;
2019
use function explode;
2120
use function is_array;
@@ -517,23 +516,23 @@ private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed):
517516
private function processUnintentionallyCoveredUnits(array $unintentionallyCoveredUnits): array
518517
{
519518
$unintentionallyCoveredUnits = array_unique($unintentionallyCoveredUnits);
520-
sort($unintentionallyCoveredUnits);
519+
$processed = [];
521520

522-
foreach (array_keys($unintentionallyCoveredUnits) as $k => $v) {
523-
$unit = explode('::', $unintentionallyCoveredUnits[$k]);
521+
foreach ($unintentionallyCoveredUnits as $unintentionallyCoveredUnit) {
522+
$tmp = explode('::', $unintentionallyCoveredUnit);
523+
524+
if (count($tmp) !== 2) {
525+
$processed[] = $unintentionallyCoveredUnit;
524526

525-
if (count($unit) !== 2) {
526527
continue;
527528
}
528529

529530
try {
530-
$class = new ReflectionClass($unit[0]);
531+
$class = new ReflectionClass($tmp[0]);
531532

532533
foreach ($this->parentClassesExcludedFromUnintentionallyCoveredCodeCheck as $parentClass) {
533534
if ($class->isSubclassOf($parentClass)) {
534-
unset($unintentionallyCoveredUnits[$k]);
535-
536-
break;
535+
continue 2;
537536
}
538537
}
539538
} catch (\ReflectionException $e) {
@@ -543,9 +542,15 @@ private function processUnintentionallyCoveredUnits(array $unintentionallyCovere
543542
$e
544543
);
545544
}
545+
546+
$processed[] = $tmp[0];
546547
}
547548

548-
return array_values($unintentionallyCoveredUnits);
549+
$processed = array_unique($processed);
550+
551+
sort($processed);
552+
553+
return $processed;
549554
}
550555

551556
private function analyser(): FileAnalyser

0 commit comments

Comments
 (0)