Permalink
Browse files

[ClassLoader] Fixed ClassMapGenerator and added suport for traits

  • Loading branch information...
1 parent 8bceaa2 commit cf6a149a5248a2b48541f5f0bd5b9b6e2217bfd6 @hason hason committed Mar 8, 2012
Showing with 3 additions and 5 deletions.
  1. +3 −5 ClassMapGenerator.php
View
@@ -84,6 +84,7 @@ static private function findClasses($path)
{
$contents = file_get_contents($path);
$tokens = token_get_all($contents);
+ $T_TRAIT = version_compare(PHP_VERSION, '5.4.0RC1', '<') ? -1 : T_TRAIT;
$classes = array();
@@ -110,6 +111,7 @@ static private function findClasses($path)
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]) {
@@ -119,11 +121,7 @@ static private function findClasses($path)
}
}
- if (empty($namespace)) {
- $classes[] = $class;
- } else {
- $classes[] = $namespace . $class;
- }
+ $classes[] = ltrim($namespace . $class, '\\');
break;
default:
break;

0 comments on commit cf6a149

Please sign in to comment.