Backport trait support in ClassMapGenerator from symfony
parent
f8a09eaa3f
commit
744f4b7c9a
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue