Browse files

Handle traits the same way as classes.

  • Loading branch information...
1 parent 87bd7bb commit cfd577baeeec3490a32e3b996c917be044e38a8f @sebastianbergmann committed Aug 7, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 PHP/CodeCoverage/Util.php
View
6 PHP/CodeCoverage/Util.php
@@ -273,11 +273,12 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
$tokens = new PHP_Token_Stream($filename);
}
- $classes = $tokens->getClasses();
+ $classes = array_merge($tokens->getClasses(), $tokens->getTraits());
$tokens = $tokens->tokens();
foreach ($tokens as $token) {
switch (get_class($token)) {
+ case 'PHP_Token_TRAIT':
case 'PHP_Token_CLASS':
case 'PHP_Token_FUNCTION': {
$docblock = $token->getDocblock();
@@ -290,7 +291,8 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
}
}
- else if ($token instanceof PHP_Token_CLASS &&
+ else if (($token instanceof PHP_Token_TRAIT ||
+ $token instanceof PHP_Token_CLASS) &&
!empty($classes[$token->getName()]['methods'])) {
$firstMethod = array_shift(
$classes[$token->getName()]['methods']

0 comments on commit cfd577b

Please sign in to comment.