You are here

class DebugUniversalClassLoader in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/class-loader/DebugUniversalClassLoader.php \Symfony\Component\ClassLoader\DebugUniversalClassLoader

Checks that the class is actually declared in the included file.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of DebugUniversalClassLoader

Deprecated

since version 2.4, to be removed in 3.0. Use the {@link \Symfony\Component\Debug\DebugClassLoader} class instead.

File

vendor/symfony/class-loader/DebugUniversalClassLoader.php, line 24

Namespace

Symfony\Component\ClassLoader
View source
class DebugUniversalClassLoader extends UniversalClassLoader {

  /**
   * Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
   */
  public static function enable() {
    if (!is_array($functions = spl_autoload_functions())) {
      return;
    }
    foreach ($functions as $function) {
      spl_autoload_unregister($function);
    }
    foreach ($functions as $function) {
      if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
        $loader = new static();
        $loader
          ->registerNamespaceFallbacks($function[0]
          ->getNamespaceFallbacks());
        $loader
          ->registerPrefixFallbacks($function[0]
          ->getPrefixFallbacks());
        $loader
          ->registerNamespaces($function[0]
          ->getNamespaces());
        $loader
          ->registerPrefixes($function[0]
          ->getPrefixes());
        $loader
          ->useIncludePath($function[0]
          ->getUseIncludePath());
        $function[0] = $loader;
      }
      spl_autoload_register($function);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function loadClass($class) {
    if ($file = $this
      ->findFile($class)) {
      require $file;
      if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
        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));
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DebugUniversalClassLoader::enable public static function Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
DebugUniversalClassLoader::loadClass public function Loads the given class or interface. Overrides UniversalClassLoader::loadClass
UniversalClassLoader::$namespaceFallbacks private property
UniversalClassLoader::$namespaces private property
UniversalClassLoader::$prefixes private property
UniversalClassLoader::$prefixFallbacks private property
UniversalClassLoader::$useIncludePath private property
UniversalClassLoader::findFile public function Finds the path to the file where the class is defined. 1
UniversalClassLoader::getNamespaceFallbacks public function Gets the directory(ies) to use as a fallback for namespaces.
UniversalClassLoader::getNamespaces public function Gets the configured namespaces.
UniversalClassLoader::getPrefixes public function Gets the configured class prefixes.
UniversalClassLoader::getPrefixFallbacks public function Gets the directory(ies) to use as a fallback for class prefixes.
UniversalClassLoader::getUseIncludePath public function Can be used to check if the autoloader uses the include path to check for classes.
UniversalClassLoader::register public function Registers this instance as an autoloader.
UniversalClassLoader::registerNamespace public function Registers a namespace.
UniversalClassLoader::registerNamespaceFallback public function Registers a directory to use as a fallback for namespaces.
UniversalClassLoader::registerNamespaceFallbacks public function Registers the directory to use as a fallback for namespaces.
UniversalClassLoader::registerNamespaces public function Registers an array of namespaces.
UniversalClassLoader::registerPrefix public function Registers a set of classes using the PEAR naming convention.
UniversalClassLoader::registerPrefixes public function Registers an array of classes using the PEAR naming convention.
UniversalClassLoader::registerPrefixFallback public function Registers a directory to use as a fallback for class prefixes.
UniversalClassLoader::registerPrefixFallbacks public function Registers directories to use as a fallback for class prefixes.
UniversalClassLoader::useIncludePath public function Turns on searching the include for class files. Allows easy loading of installed PEAR packages.