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

@param string $class The name of the class

@return string|null The path, if found
2312
public function findFile($class)
    {
        if (false !== $pos = strrpos($class, '\\')) {
            // namespaced class name
            $namespace = substr($class, 0, $pos);
            $className = substr($class, $pos + 1);
            $normalizedClass = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
            foreach ($this->namespaces as $ns => $dirs) {
                if (0 !== strpos($namespace, $ns)) {
                    continue;
                }

                foreach ($dirs as $dir) {
                    $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
                    if (is_file($file)) {
                        return $file;
                    }
                }
            }

            foreach ($this->namespaceFallbacks as $dir) {
                $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
                if (is_file($file)) {
                    return $file;
                }
            }

        } else {
            // PEAR-like class name
            $normalizedClass = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
            foreach ($this->prefixes as $prefix => $dirs) {
                if (0 !== strpos($class, $prefix)) {
                    continue;
                }

                foreach ($dirs as $dir) {
                    $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
                    if (is_file($file)) {
                        return $file;
                    }
                }
            }

            foreach ($this->prefixFallbacks as $dir) {
                $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
                if (is_file($file)) {
                    return $file;
                }
            }
        }

        if ($this->useIncludePath && $file = stream_resolve_include_path($normalizedClass)) {
            return $file;
        }
    }
549148
public function findFile($class)
    {
        $class = Normalizer::ns($class, false);
        if (isset($this->classMap[$class])) {
            return $this->classMap[$class];
        }
        $index = substr($class, 0, 4);
        if (isset($this->indexes[$index])) {
            $namespace = $class;
            while (false !== $pos = strrpos($namespace, '\\')) {
                $namespace = substr($class, 0, $pos + 1);
                if (! isset($this->paths[$namespace])) {
                    $namespace = rtrim($namespace, '\\');
                    continue;
                }
                $subclass = substr($class, $pos + 1);
                $subpath  = Normalizer::path($subclass, false) . '.php';
                foreach ($this->paths[$namespace] as $dir) {
                    $path = $dir . $subpath;
                    if (is_readable($path)) {
                        if ($this->classRegistration) {
                            $this->classMap[$class] = $path;
                        }

                        return $path;
                    }
                }
                $namespace = rtrim($namespace, '\\');
            }
        }

        if ($this->classRegistration) {
            $this->classMap[$class] = false;
        }

        return false;
    }
672252
protected function getPsr4ClassPath($class)
    {
        $options = $this->context->getOptions();
        $psr4    = $options->getPsr4() ?: [];
        $class   = trim($class, '\\');

        foreach ($psr4 as $item) {
            $prefix = trim($item, '\\') . '\\';
            $length = strlen($prefix);
            $start  = substr($class, 0, $length);

            if ($start !== $prefix) {
                continue;
            }

            $name = trim(str_replace($prefix, '', $class), '\\');
            $path = $this->getClassPath($name);

            return $path;
        }

        return $this->getClassPath($class);
    }
919927
protected function getFromCache($class, $path)
    {
        if (!isset($this->classCache[$class])) {
            return null;
        }

        if (!$path) {
            return $this->classCache[$class];
        }

        if (!isset($this->pathCache[$class])) {
            $this->putAllIntoCache($class, $this->classCache[$class]);
        }

        if (isset($this->pathCache[$class][$path])) {
            return $this->pathCache[$class][$path];
        }

        if (!strpos($path, '.')) {
            return null;
        }

        $segments = explode('.', $path);

        $type = null;
        $currentClass = $class;

        foreach ($segments as $segment) {

            if (!$type = $this->getFromCache($currentClass, $segment)) {
                 return null;
            }

            if ($type instanceof ObjectType) {
                $currentClass = $type->class;
            }

            if (!$type instanceof HasTypedItems) {
                continue;
            }

            if ($type->itemType instanceof ObjectType) {
                $currentClass = $type->itemType->class;
            }

        }

        return $type;

    }
558508
protected function getFileFinder($file) {
    return new class($file) implements ClassFinderInterface {

      protected $file;

      public function __construct($file) {
        $this->file = $file;
      }

      public function findFile($class) {
        return $this->file;
      }
    };
  }
634070
public function findClass($class)
    {
        if (strrpos($class, '\\') !== false) {
            $file = Loaders\Psr4::getInstance()->findClass($class);
            if (!$file) {
                $file = Loaders\Psr0::getInstance()->findClass($class);
            }
        } else {
            $file = Loaders\Pear::getInstance()->findClass($class);
        }

        return $file;
    }
785574
public function findFile($strClass)
    {
        if (isset($this->classmap[$strClass])) {
            $strFile = $this->classmap[$strClass];
        }
        else {
            $strFile = $this->composerAutoloader->findFile($strClass);
        }

        if ($strFile && file_exists($strFile)) {
            return $strFile;
        }
        else {
            return null;
        }
    }
214960
public function findFile($class)
    {
        if (false === $file = apc_fetch($this->prefix.$class)) {
            apc_store($this->prefix.$class, $file = $this->decorated->findFile($class));
        }

        return $file;
    }
1116789
private function getResourcePathFromClassName($class)
    {
        $reflection = new \ReflectionClass($class);

        if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/contao')) {
            return $dir;
        }

        return null;
    }
1188649
public static function getPath($class)
    {
        if (strncmp('HTMLPurifier', $class, 12) !== 0) {
            return false;
        }
        // Custom implementations
        if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) {
            $code = str_replace('_', '-', substr($class, 22));
            $file = 'HTMLPurifier/Language/classes/' . $code . '.php';
        } else {
            $file = str_replace('_', '/', $class) . '.php';
        }
        if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) {
            return false;
        }
        return $file;
    }
1019688
public function findFile($class)
    {
        // class map lookup
        if (isset($this->_classMap[$class])) {
            return $this->_classMap[$class];
        }
        if ($this->_classMapAuthoritative || isset($this->_missingClasses[$class])) {
            return false;
        }
        if ($this->_apcuPrefix !== null) {
            $file = apcu_fetch($this->_apcuPrefix . $class, $hit);
            if ($hit) {
                return $file;
            }
        }

        $file = $this->_findFileWithExtension($class, '.php');

        // Search for Hack files if we are running on HHVM
        if (!$file && defined('HHVM_VERSION')) {
            $file = $this->_findFileWithExtension($class, '.hh');
        }

        if ($this->_apcuPrefix !== null) {
            apcu_add($this->_apcuPrefix . $class, $file);
        }

        if ($file !== false) {
            $file = realpath($file);
        } else {
            // Remember that this class does not exist.
            $this->_missingClasses[$class] = true;
        }
        return $this->_patchers ? $this->_patchers->findFile($this, $class, $file) : $file;
    }
130361
public function resolveClass( $class )
	{
		if ( !is_string( $class ) )
			throw new ResolverException( "Class must be a string" );

		// Check if a class has been mapped to a key
		if ( array_key_exists( $class, $this->classAlias ) )
			try
			{
				return $this->resolve( null, $this->classAlias[$class] );
			}
			catch ( ResolverException $e )
			{
				// Ignore
			}

		// Check if the class has been initialized
		foreach ( $this->instances as $instance )
			if ( get_class( $instance ) == $class )
				return $instance;

		// TODO Other methods to check?

		return false;
	}
908530
public function findFile($class)
    {
        $file = apc_fetch($this->key . $class);

        if (!$file) {
            $file = $this->loader->findFile($class);
            apc_store($this->key . $class, $file);
        }

        return $file;
    }
1002753
public function locate($class)
    {
        if (strpos($class, '\\') !== false)
        {
            foreach($this->getNamespaces() as $prefix => $basepaths)
            {
                if(strpos('\\'.$class, '\\'.$prefix) !== 0) {
                    continue;
                }

                if (strpos($class, $prefix) === 0) {
                    $class = trim(substr($class, strlen($prefix)), '\\');
                }

                $path = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class) . '.php';

                foreach($basepaths as $basepath)
                {
                    $result = $basepath . '/' .$path;
                    if (is_file($result)) {
                        break;
                    }
                }
            }
        }

        return false;
    }
740235
private function locate($class)
    {
        if ($this->apcEnabled && !$file = apc_fetch($class)) {
            if ($file = $this->locateFile($class)) {
                apc_store($class, $file);
            }
        } elseif (!$this->apcEnabled) {
            $file = $this->locateFile($class);
        }

        return $file;
    }
310856
public function find($class)
    {
        $reflectionClass = new \ReflectionClass($class);

        do {
            $classNamespace = $reflectionClass->getNamespaceName();
            foreach ($this->bundles as $bundleName => $bundleClass) {
                $bundleNamespace = \substr($bundleClass, 0, \strrpos($bundleClass, '\\'));
                if (0 === \strpos($classNamespace, $bundleNamespace)) {
                    return $bundleName;
                }
            }
            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);

        return null;
    }
1084969
public function get($class = null)
        {
            $class = $this->getClass($class);

            if (Arrays::exists($class, $this->reflections)) {
                return $this->reflections[$class];
            }

            throw new Exception("Class not found: $class");
        }