Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,22 +714,24 @@ private function getLinesToBeIgnored($filename)
$stop = true;
}

// Do not ignore the whole line when there is a token
// before the comment on the same line
if (0 === strpos($_token, $_line)) {
$count = substr_count($token, "\n");
$line = $token->getLine();
if (!$ignore) {
$start = $token->getLine();
$end = $start + substr_count($token, "\n");

// Do not ignore the first line when there is a token
// before the comment
if (0 !== strpos($_token, $_line)) {
$start++;
}

for ($i = $line; $i < $line + $count; $i++) {
for ($i = $start; $i < $end; $i++) {
$this->ignoredLines[$filename][] = $i;
}

if ($token instanceof PHP_Token_DOC_COMMENT) {
// The DOC_COMMENT token does not contain the
// final \n character in its text
if (substr(trim($lines[$i-1]), -2) == '*/') {
$this->ignoredLines[$filename][] = $i;
}
// A DOC_COMMENT token or a COMMENT token starting with "/*"
// does not contain the final \n character in its text
if (0 === strpos($_token, '/*') && '*/' === substr(trim($lines[$i-1]), -2)) {
$this->ignoredLines[$filename][] = $i;
}
}
break;
Expand Down
3 changes: 3 additions & 0 deletions tests/PHP/CodeCoverageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,11 @@ public function testGetLinesToBeIgnoredOneLineAnnotations()
16,
18,
20,
21,
23,
24,
25,
27,
28,
29,
30,
Expand Down