Skip to content
This repository
Browse code

Handle traits the same way as classes.

  • Loading branch information...
commit cfd577baeeec3490a32e3b996c917be044e38a8f 1 parent 87bd7bb
Sebastian Bergmann authored

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. +4 2 PHP/CodeCoverage/Util.php
6 PHP/CodeCoverage/Util.php
@@ -273,11 +273,12 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
273 273 $tokens = new PHP_Token_Stream($filename);
274 274 }
275 275
276   - $classes = $tokens->getClasses();
  276 + $classes = array_merge($tokens->getClasses(), $tokens->getTraits());
277 277 $tokens = $tokens->tokens();
278 278
279 279 foreach ($tokens as $token) {
280 280 switch (get_class($token)) {
  281 + case 'PHP_Token_TRAIT':
281 282 case 'PHP_Token_CLASS':
282 283 case 'PHP_Token_FUNCTION': {
283 284 $docblock = $token->getDocblock();
@@ -290,7 +291,8 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
290 291 }
291 292 }
292 293
293   - else if ($token instanceof PHP_Token_CLASS &&
  294 + else if (($token instanceof PHP_Token_TRAIT ||
  295 + $token instanceof PHP_Token_CLASS) &&
294 296 !empty($classes[$token->getName()]['methods'])) {
295 297 $firstMethod = array_shift(
296 298 $classes[$token->getName()]['methods']

0 comments on commit cfd577b

Please sign in to comment.
Something went wrong with that request. Please try again.