src/Autoloader.php
public function autoload($class_name)
    {
        // Basic check
        if (class_exists($class_name, false))
            return;

        // Use cache when available
        if ($this->cache !== null)
        {
            $cache_built = $this->cache->dget('cache_built', false);

            $path = $this->cache->get('classpaths', $class_name);
            if ($this->authorative && ($path === false || ($cache_built && $path === null)))
                return; // Authorative, no match found, so no loading

            if (!empty($path))
            {
                require_once $path;
                return;
            }

            // No match found, not authorative. Keep looking
        }

        $loaders = $this->getClassLoaders($class_name);
        foreach ($loaders as $loader)
        {
            $path = null;
            if ($loader['std'] === Autoloader::PSR0)
            {
                $path = self::findPSR0($loader['ns'], $class_name, $loader['path']);
            }
            elseif ($loader['std'] === Autoloader::PSR4)
            {
                $path = self::findPSR4($loader['ns'], $class_name, $loader['path']);
            }
            elseif (is_callable($loader['std']))
            {
                try
                {
                    $path = $loader['std']($class_name);
                }
                catch (\Throwable $e)
                {
                    self::getLogger()->critical(
                        'Class loader for {ns} threw exception with ' .
                        'attempting to load class {class}: {exception}', 
                        ['ns' => $loader['ns'], 'exception' => $e, 'class' => $class_name]
                    );
                } // Don't throw any errors
            }

            if (empty($path))
                continue;

            require_once $path;
            
            $exists = class_exists($class_name) || trait_exists($class_name) || interface_exists($class_name);
            if (self::$logger)
            {
                if (trait_exists($class_name))
                    self::$logger->debug("Loaded trait {0} from path {1}", [$class_name, $path]);
                elseif (interface_exists($class_name))
                    self::$logger->debug("Loaded interface {0} from path {1}", [$class_name, $path]);
                elseif (class_exists($class_name, false))
                    self::$logger->debug("Loaded class {0} from path {1}", [$class_name, $path]);
                else
                    self::$logger->error("File {0} does not contain class {1}", [$path, $class_name]);
            }

            // When a class has been loaded, don't loop any further
            if ($exists)
                break;
        }

        // Cache resolved path
        if ($this->cache !== null)
        {
            if (!empty($path))
                $this->cache->set('classpaths', $class_name, $path);
            else // Cache failure
                $this->cache->set('classpaths', $class_name, false);
        }
    }
public function autoload($class_name)
    {
        // Basic check
        if (class_exists($class_name, false))
            return;

        // Use cache when available
        if ($this->cache !== null)
        {
            $cache_built = $this->cache->dget('cache_built', false);

            $path = $this->cache->get('classpaths', $class_name);
            if ($this->authorative && ($path === false || ($cache_built && $path === null)))
                return; // Authorative, no match found, so no loading

            if (!empty($path))
            {
                require_once $path;
                return;
            }

            // No match found, not authorative. Keep looking
        }

        $loaders = $this->getClassLoaders($class_name);
        foreach ($loaders as $loader)
        {
            $path = null;
            if ($loader['std'] === Autoloader::PSR0)
            {
                $path = self::findPSR0($loader['ns'], $class_name, $loader['path']);
            }
            elseif ($loader['std'] === Autoloader::PSR4)
            {
                $path = self::findPSR4($loader['ns'], $class_name, $loader['path']);
            }
            elseif (is_callable($loader['std']))
            {
                try
                {
                    $path = $loader['std']($class_name);
                }
                catch (\Throwable $e)
                {
                    self::getLogger()->critical(
                        'Class loader for {ns} threw exception with ' .
                        'attempting to load class {class}: {exception}', 
                        ['ns' => $loader['ns'], 'exception' => $e, 'class' => $class_name]
                    );
                } // Don't throw any errors
            }

            if (empty($path))
                continue;

            require_once $path;
            
            $exists = class_exists($class_name) || trait_exists($class_name) || interface_exists($class_name);
            if (self::$logger)
            {
                if (trait_exists($class_name))
                    self::$logger->debug("Loaded trait {0} from path {1}", [$class_name, $path]);
                elseif (interface_exists($class_name))
                    self::$logger->debug("Loaded interface {0} from path {1}", [$class_name, $path]);
                elseif (class_exists($class_name, false))
                    self::$logger->debug("Loaded class {0} from path {1}", [$class_name, $path]);
                else
                    self::$logger->error("File {0} does not contain class {1}", [$path, $class_name]);
            }

            // When a class has been loaded, don't loop any further
            if ($exists)
                break;
        }

        // Cache resolved path
        if ($this->cache !== null)
        {
            if (!empty($path))
                $this->cache->set('classpaths', $class_name, $path);
            else // Cache failure
                $this->cache->set('classpaths', $class_name, false);
        }
    }
The spl_autoloader that loads classes registered namespaces
@param string $class_name The class to load