You are here

public function ClassLoader::findFile in Zircon Profile 8

Same name in this branch
  1. 8 vendor/composer/ClassLoader.php \Composer\Autoload\ClassLoader::findFile()
  2. 8 vendor/symfony/class-loader/ClassLoader.php \Symfony\Component\ClassLoader\ClassLoader::findFile()
  3. 8 vendor/symfony/debug/Tests/DebugClassLoaderTest.php \Symfony\Component\Debug\Tests\ClassLoader::findFile()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/class-loader/ClassLoader.php \Symfony\Component\ClassLoader\ClassLoader::findFile()

Finds the path to the file where the class is defined.

Parameters

string $class The name of the class:

Return value

string|null The path, if found

1 call to ClassLoader::findFile()
ClassLoader::loadClass in vendor/symfony/class-loader/ClassLoader.php
Loads the given class or interface.

File

vendor/symfony/class-loader/ClassLoader.php, line 169

Class

ClassLoader
ClassLoader implements an PSR-0 class loader.

Namespace

Symfony\Component\ClassLoader

Code

public function findFile($class) {
  if (false !== ($pos = strrpos($class, '\\'))) {

    // namespaced class name
    $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
    $className = substr($class, $pos + 1);
  }
  else {

    // PEAR-like class name
    $classPath = null;
    $className = $class;
  }
  $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
  foreach ($this->prefixes as $prefix => $dirs) {
    if ($class === strstr($class, $prefix)) {
      foreach ($dirs as $dir) {
        if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
          return $dir . DIRECTORY_SEPARATOR . $classPath;
        }
      }
    }
  }
  foreach ($this->fallbackDirs as $dir) {
    if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
      return $dir . DIRECTORY_SEPARATOR . $classPath;
    }
  }
  if ($this->useIncludePath && ($file = stream_resolve_include_path($classPath))) {
    return $file;
  }
}