1
0
Fork 0

Backport trait support in ClassMapGenerator from symfony

pull/422/head
Jordi Boggiano 2012-03-10 02:00:29 +01:00
parent f8a09eaa3f
commit 744f4b7c9a
1 changed files with 3 additions and 6 deletions

View File

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