4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\ClassLoader;
14 @trigger_error('The '.__NAMESPACE__.'\DebugUniversalClassLoader class is deprecated since version 2.4 and will be removed in 3.0. Use the Symfony\Component\Debug\DebugClassLoader class instead.', E_USER_DEPRECATED);
17 * Checks that the class is actually declared in the included file.
19 * @author Fabien Potencier <fabien@symfony.com>
21 * @deprecated since version 2.4, to be removed in 3.0.
22 * Use the {@link \Symfony\Component\Debug\DebugClassLoader} class instead.
24 class DebugUniversalClassLoader extends UniversalClassLoader
27 * Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
29 public static function enable()
31 if (!is_array($functions = spl_autoload_functions())) {
35 foreach ($functions as $function) {
36 spl_autoload_unregister($function);
39 foreach ($functions as $function) {
40 if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
41 $loader = new static();
42 $loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
43 $loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
44 $loader->registerNamespaces($function[0]->getNamespaces());
45 $loader->registerPrefixes($function[0]->getPrefixes());
46 $loader->useIncludePath($function[0]->getUseIncludePath());
48 $function[0] = $loader;
51 spl_autoload_register($function);
58 public function loadClass($class)
60 if ($file = $this->findFile($class)) {
63 if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
64 throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));