Skip to content

Commit 6f7ffe4

Browse files
Slamdunkmvorisek
authored andcommitted
Add coverage for empty methods
1 parent 5a91561 commit 6f7ffe4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ private function getLines(NodeAbstract $node, bool $fromReturns): array
188188

189189
if ($node instanceof ClassMethod) {
190190
if ($node->name->name !== '__construct') {
191+
if ($node->stmts === []) {
192+
return [$node->getEndLine()];
193+
}
194+
191195
return [];
192196
}
193197

tests/_files/source_with_multiline_constant_return.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,4 +515,14 @@ public function concatWithVar(): string
515515

516516
return $var1;
517517
}
518+
519+
public
520+
function
521+
emptyMethod
522+
(
523+
)
524+
:
525+
void
526+
{
527+
}
518528
}

tests/tests/Data/RawCodeCoverageDataTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
504504
508,
505505
512, // This is correct: not the line with the $var1, but the right operand of the Concat
506506
516,
507+
527,
507508
],
508509
array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingFileAnalyser(true, true))->lineCoverage()[$file])
509510
);

0 commit comments

Comments
 (0)