public function ClassLoader::findFile

Same name in this branch
  1. 8.x drupal/core/vendor/composer/ClassLoader.php \Composer\Autoload\ClassLoader::findFile()
  2. 8.x drupal/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/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|false The path if found, false otherwise

1 call to ClassLoader::findFile()
ClassLoader::loadClass in drupal/core/vendor/composer/ClassLoader.php
Loads the given class or interface.

File

drupal/core/vendor/composer/ClassLoader.php, line 198

Class

ClassLoader
ClassLoader implements a PSR-0 class loader

Namespace

Composer\Autoload

Code

public function findFile($class) {

  // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
  if ('\\' == $class[0]) {
    $class = substr($class, 1);
  }
  if (isset($this->classMap[$class])) {
    return $this->classMap[$class];
  }
  if (false !== ($pos = strrpos($class, '\\'))) {

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

    // PEAR-like class name
    $classPath = null;
    $className = $class;
  }
  $classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';
  $first = $class[0];
  if (isset($this->prefixes[$first])) {
    foreach ($this->prefixes[$first] as $prefix => $dirs) {
      if (0 === strpos($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;
  }
  return $this->classMap[$class] = false;
}