-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
In the latest version 3.2+ version of Symfony, I see that we have a new function to get and dump the classes for caching.
private function getClassesInComposerClassMaps()
{
$classes = array();
foreach (spl_autoload_functions() as $function) {
if (!is_array($function)) {
continue;
}
if ($function[0] instanceof DebugClassLoader) {
$function = $function[0]->getClassLoader();
}
if (is_array($function) && $function[0] instanceof ClassLoader) {
$map = $function[0]->getClassMap();
$classes += $function[0]->getClassMap();
}
}
return array_keys($classes);
}
The problem with this is, say for example if before running this method we call class_exist method with the default $autoload option set to true (http://php.net/manual/en/function.class-exists.php) then this class, existing or not, will be registered to the list of spl_autoload_functions.
In short, the result from getClassesInComposerClassMaps actually contains classes that do not exist and not meant to exist.
A quick cleanup at the end seems to fix the immediate issue but I'm not sure if there is anything else.
foreach ($classes as $k => $v) {
if (false === $v) {
unset($classes[$k]);
}
}