Finds a file by class name while caching lookups to APC.

@param string $class A class name to resolve to file

@return string|null The path, if found
775436
public function findFile($class)
    {
        if (false === $file = apc_fetch($this->prefix.$class)) {
            apc_store($this->prefix.$class, $file = parent::findFile($class));
        }

        return $file;
    }
1019568
public function findFile(string $class)
    {
        static $isAllowedFilter = null, $isProduction = false;
        if (!$isAllowedFilter) {
            $isAllowedFilter = $this->fileEnumerator->getFilter();
            $isProduction    = !$this->options['debug'];
        }

        $file = $this->original->findFile($class);

        if ($file !== false) {
            $file = PathResolver::realpath($file)?:$file;
            $cacheState = $this->cacheState[$file] ?? null;
            if ($cacheState && $isProduction) {
                $file = $cacheState['cacheUri'] ?: $file;
            } elseif ($isAllowedFilter(new \SplFileInfo($file))) {
                // can be optimized here with $cacheState even for debug mode, but no needed right now
                $file = FilterInjectorTransformer::rewrite($file);
            }
        }

        return $file;
    }
1288187
public function loadClass($class)
    {
        if (!$file = $this->findFile($class)) {
            return;
        }

        if (!$this->_patchers || !$this->patchable($class)) {
            includeFile($file);
            return true;
        }
        return $this->loadFile($file);
    }
346545
protected function nearestForClass($findClass)
    {

        if (isset($this->_cache[$findClass])) {
            return $this->_cache[$findClass];
        }

        if (!count($this->_extensions)) {
            return null;
        }

        if (isset($this->_extensions[$findClass])) {
            $this->_cache[$findClass] = $this->_extensions[$findClass];
            return $this->_cache[$findClass];
        }

        if (!$nearest = $this->findNearestForClass($this->_extensions, $findClass)) {
            return null;
        }

        $this->_cache[$findClass] = $nearest;

        return $nearest;

    }
536706
public function findFile($class) {
		if ('\\' === $class[0]) {
			$class = substr($class, 1);
		}

		if (isset($this->classMap[$class])) {
			return $this->classMap[$class];
		}
		elseif ($this->classMapAuthoratative) {
			return false;
		}

		$classPath = $this->getClassPath($class);

		foreach ($this->prefixes 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 = self::resolveIncludePath($classPath)) {
			return $file;
		}

		return $this->classMap[$class] = false;
	}
911555
public function load(string $class)
    {
        $alias = $this->loader;
        if (isset($alias[$class])) {
            class_alias($alias[$class], $class);
        }

        $class = $this->alias($class);
        if (!$this->container->has($class)) {
            return null;
        }

        $instance = $this->container[$class];
        if (is_object($instance)) {
            return $instance;
        }

        return null;
    }
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;
        }
    }
888133
protected function findProxyFile(string $class): ?string
    {
        $class = substr($class, 24);

        $filePath = $this->directory . '/Proxy/' . str_replace('\\', '/', $class) . '.php';

        if (file_exists($filePath) && is_file($filePath)) {
            return $filePath;
        }

        return null;
    }
50904
public function getLocator($class)
    {
        $result = false;

        if(!false == $pos = strrpos($class, '\\'))
        {
            $namespace = substr($class, 0, $pos);

            if(isset($this->_namespaces[$namespace])) {
                $result = $this->_namespaces[$namespace];
            }
        }

        return $result;
    }
469009
public static function find( $class ) 
	{	
		if ( class_exists( $class, false ) )
		{
			return;
		}

		// class with or without namespace?
		if ( strpos( $class , '\\' ) !== false ) 
		{
			/*
			 * alias map
			 */
			if ( array_key_exists( $class, static::$aliases ) ) 
			{
				require static::$aliases[$class];
			}
			/* 
			 * normal map
			 */
			elseif ( array_key_exists( $class, static::$classes ) ) 
			{
				require static::$classes[$class];
			}
			/*
			 * try your luck without the map
			 */
			else 
			{	
				$namespace = substr( $class, 0, strrpos( $class, "\\" ) );
				$class_name = substr( $class, strrpos( $class, "\\" )+1 );
				
				if ( !array_key_exists( $namespace, static::$namespaces ) ) 
				{
					return false;
				}
				
				$path = static::$namespaces[$namespace].str_replace( '_', '/', $class_name ).EXT;
				
				if ( !file_exists( $path ) ) 
				{
					return false;
				}
				
				require $path;
			}
			
			/*
			 * check if we need to create a shadow aka an alias
			 */
			if ( in_array( $class, static::$shadows ) )
			{
				$shadow = array_search( $class, static::$shadows );
				
				if ( !class_exists( $shadow, false ) && !array_key_exists( $shadow, static::$aliases ) )
				{
					class_alias( $class, $shadow ); 
				}
			}
		}
		else 
		{
			/*
			 * alias map
			 */
			if ( array_key_exists( $class, static::$aliases ) ) 
			{
				require static::$aliases[$class];
			}
			/*
			 * check shadows
			 */
			if ( array_key_exists( $class, static::$shadows ) )
			{
				return static::find( static::$shadows[$class] );
			}
			/* 
			 * normal map
			 */
			elseif ( array_key_exists( $class, static::$classes ) ) 
			{
				require static::$classes[$class];
			}
			/*
			 * try your luck without the map
			 */
			else 
			{
				$path = APPPATH.CCDIR_CLASS.str_replace( '_', '/', $class ).EXT;
				
				if ( !file_exists( $path ) ) 
				{
					return false;
				}
				
				require $path ;
			}
		}
		
		/*
		 * run the static init if possible
		 */
		if ( method_exists( $class, '_init' ) ) 
		{
			$class::_init();
		}
		
		return true;
	}
898882
public function resolve($class)
    {
        $result = false;
        $prefix = $class;

        while (false !== ($pos = strrpos($prefix, '\\'))) {
            $prefix = substr($class, 0, $pos + 1);

            if (isset($this->prefixes[$prefix])) {
                $result = $this->resolveFilename($prefix, str_replace('\\', '/', substr($class, $pos + 1)));

                if ($result !== false) {
                    break;
                }
            }

            $prefix = rtrim($prefix, '\\');
        }

        return $result;
    }
614602
private function load($class)
    {
        if ($this->isLoaded($class)) {
            throw new \InvalidArgumentException(sprintf(
                "Error loading class '%s', the class already exists",
                $class
            ));
        }

        if ($file = $this->findFile($class)) {
            return $this->loadFile($file, $class);
        }

        return false;
    }
949825
public function resolveClass(string $class)
    {
        $object = $this->getClass($class);

        $definitions = $this->container->isDefined($object->getName())
            ? $this->container->getDefiniition($object->getName()) : null;

        $constructor_parameters = $object->getConstructor() !== null ? $object->getConstructor()->getParameters() : null;
        $parameters = $this->resolveParameters($constructor_parameters ?? [], $definitions);

        return $object->newInstanceArgs($parameters);
    }
623529
public function locateClass($className)
    {
        $filePath = $this->loader->findFile(ltrim($className, '\\'));
        if (!empty($filePath)) {
            $filePath = PathResolver::realpath($filePath);
        }

        return $filePath;
    }
823992
private function findClassInPath($path, $class, $prefix)
    {
        if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
            return array();
        }

        $classes = array();
        $filename = $class.'.php';
        foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
            if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
                $classes[] = $class;
            }
        }

        return $classes;
    }
944588
public function findFileForClass(\ReflectionClass $class, $extension)
    {
        foreach ($this->dirs as $prefix => $dir) {
            if ('' !== $prefix && 0 !== strpos($class->getNamespaceName(), $prefix)) {
                continue;
            }

            $len = '' === $prefix ? 0 : strlen($prefix) + 1;
            $path = $dir . '/' . str_replace('\\', '.', substr($class->name, $len)) . '.' . $extension;

            if ($this->repository->contains($path)) {
                return $this->repository->get($path)->getFilesystemPath();
            }
        }

        return null;
    }
201322
public function getClassAnnotation($class)
    {
        $reflClass = new \ReflectionClass($class);
        $mappedDocumentClass = static::ANNOTATION_CLASS_CLASS;

        foreach ($this->annotationReader->getClassAnnotations($reflClass) as $annotation) {
            if ($annotation instanceof $mappedDocumentClass) {
                return $annotation;
            }
        }

        return null;
    }