You are here

public function DebugClassLoader::loadClass in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/debug/DebugClassLoader.php \Symfony\Component\Debug\DebugClassLoader::loadClass()
  2. 8.0 vendor/symfony/class-loader/DebugClassLoader.php \Symfony\Component\ClassLoader\DebugClassLoader::loadClass()
Same name and namespace in other branches
  1. 8 vendor/symfony/class-loader/DebugClassLoader.php \Symfony\Component\ClassLoader\DebugClassLoader::loadClass()

Loads the given class or interface.

Parameters

string $class The name of the class:

Return value

bool|null True, if loaded

Throws

\RuntimeException

File

vendor/symfony/class-loader/DebugClassLoader.php, line 104

Class

DebugClassLoader
Autoloader checking if the class is really defined in the file found.

Namespace

Symfony\Component\ClassLoader

Code

public function loadClass($class) {
  if ($file = $this->classFinder
    ->findFile($class)) {
    require $file;
    if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
      if (false !== strpos($class, '/')) {
        throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\\" in PHP, not "/".', $class));
      }
      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));
    }
    return true;
  }
}