|
44 | 44 | */ |
45 | 45 |
|
46 | 46 | /** |
47 | | - * |
| 47 | + * |
48 | 48 | * |
49 | 49 | * @category PHP |
50 | 50 | * @package CodeCoverage |
@@ -164,22 +164,24 @@ public function getLinesToBeIgnored($filename) |
164 | 164 | $stop = true; |
165 | 165 | } |
166 | 166 |
|
167 | | - // Do not ignore the whole line when there is a token |
168 | | - // before the comment on the same line |
169 | | - if (0 === strpos($_token, $_line)) { |
170 | | - $count = substr_count($token, "\n"); |
171 | | - $line = $token->getLine(); |
| 167 | + if (!$ignore) { |
| 168 | + $start = $token->getLine(); |
| 169 | + $end = $start + substr_count($token, "\n"); |
| 170 | + |
| 171 | + // Do not ignore the first line when there is a token |
| 172 | + // before the comment |
| 173 | + if (0 !== strpos($_token, $_line)) { |
| 174 | + $start++; |
| 175 | + } |
172 | 176 |
|
173 | | - for ($i = $line; $i < $line + $count; $i++) { |
| 177 | + for ($i = $start; $i < $end; $i++) { |
174 | 178 | $this->ignoredLines[$filename][] = $i; |
175 | 179 | } |
176 | 180 |
|
177 | | - if ($token instanceof PHP_Token_DOC_COMMENT) { |
178 | | - // The DOC_COMMENT token does not contain the |
179 | | - // final \n character in its text |
180 | | - if (substr(trim($lines[$i-1]), -2) == '*/') { |
181 | | - $this->ignoredLines[$filename][] = $i; |
182 | | - } |
| 181 | + // A DOC_COMMENT token or a COMMENT token starting with "/*" |
| 182 | + // does not contain the final \n character in its text |
| 183 | + if (0 === strpos($_token, '/*') && '*/' === substr(trim($lines[$i-1]), -2)) { |
| 184 | + $this->ignoredLines[$filename][] = $i; |
183 | 185 | } |
184 | 186 | } |
185 | 187 | break; |
|
0 commit comments