diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index c9fa687d6..99b2a29ad 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -85,6 +85,7 @@ class ClassMapGenerator { $contents = file_get_contents($path); $tokens = token_get_all($contents); + $T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT; $classes = array(); @@ -111,6 +112,7 @@ class ClassMapGenerator break; case T_CLASS: case T_INTERFACE: + case $T_TRAIT: // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { @@ -120,11 +122,7 @@ class ClassMapGenerator } } - if (empty($namespace)) { - $classes[] = $class; - } else { - $classes[] = $namespace . $class; - } + $classes[] = ltrim($namespace . $class, '\\'); break; default: break; @@ -134,4 +132,3 @@ class ClassMapGenerator return $classes; } } -