diff --git a/composer.json b/composer.json index c9cac91a2..a27624f82 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "sebastian/version": ">=1.0.0" }, "require-dev": { - "phpunit/phpunit": "4.2.*@dev", + "phpunit/phpunit": "4.3.*@dev", "ext-xdebug": ">=2.1.4" }, "suggest": { diff --git a/src/CodeCoverage/Parser.php b/src/CodeCoverage/Parser.php index aa7007a67..63c141ae5 100644 --- a/src/CodeCoverage/Parser.php +++ b/src/CodeCoverage/Parser.php @@ -44,7 +44,7 @@ */ /** - * + * * * @category PHP * @package CodeCoverage @@ -164,22 +164,24 @@ public 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; diff --git a/tests/PHP/CodeCoverage/ParserTest.php b/tests/PHP/CodeCoverage/ParserTest.php index 59f46ac40..7ce366676 100644 --- a/tests/PHP/CodeCoverage/ParserTest.php +++ b/tests/PHP/CodeCoverage/ParserTest.php @@ -108,8 +108,11 @@ public function ignoredLinesProvider() 16, 18, 20, + 21, 23, 24, + 25, + 27, 28, 29, 30,