Handles autoloading of classes that have been registered in this instance

@param string $class A class name.

@return boolean Returns true if the class has been loaded
492893
public function autoload($class)
    {
        if (isset($this->classes[$class])) {
            require $this->classes[$class];

            return true;
        }
        // fallback for classes defined with leading backslash
        if (strpos($class, '\\') === 0) {
            $class = substr($class, 1);

            return $this->autoload($class);
        }

        return false;
    }
200354
public function hasClass($class)
    {
        $classes = explode(' ', strtolower($this->extraClass()));
        return in_array(strtolower(trim($class)), $classes);
    }
190335
public function getAllClasses($class, bool $autoload = true): array
    {
        if (is_object($class)) {
            $class = get_class($class);
        }

        if (!isset($this->classes[$class])) {
            $classes = array_merge([ltrim($class, '\\')],
                                   $resultClassParents = @class_parents($class, $autoload),
                                   $resultClassImplements = @class_implements($class, $autoload));

            if ($resultClassParents === false || $resultClassImplements === false) {
                throw new ClassIndexException(sprintf('Unable to get all classes of class "%s"', $class));
            }

            $this->classes[$class] = array_unique($classes);
        }

        return $this->classes[$class];
    }
555657
public function load($class)
    {
        if ($class[0] == '\\') $class = substr($class, 1);
        $class = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class).'.php';

        foreach ($this->directories as $directory)
        {
            if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$class))
            {
                require_once $path;
                return true;
            }
        }
        return false;
    }
444756
public static function loadClass($class)
    {
        if (isset(self::$_classMap[$class]))
            return (bool)require sprintf('%s/%s', self::ROOT_DIR, self::$_classMap[$class]);
        return null;
    }
1091528
public function loadClass($class)
    {
        $e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);

        try {
            if ($this->isFinder && !isset($this->loaded[$class])) {
                $this->loaded[$class] = true;
                if (!$file = $this->classLoader[0]->findFile($class) ?: false) {
                    // no-op
                } elseif (\function_exists('opcache_is_script_cached') && @opcache_is_script_cached($file)) {
                    require $file;

                    return;
                } else {
                    require $file;
                }
            } else {
                ($this->classLoader)($class);
                $file = false;
            }
        } finally {
            error_reporting($e);
        }

        $this->checkClass($class, $file);
    }
1359299
public function autoload($class) {
        $classKey = strtolower($class);

        if (isset($this->classes[$classKey])) {
            list($_, $path) = $this->classes[$classKey];
            include_once $path;
        }
    }
1246662
protected function loadInstanceFromClass($class) {
        $arguments = $this->getConfiguration() [ AbstractFileConfiguration::SERVICE_INIT_ARGUMENTS ] ?? NULL;
        $config = $this->getConfiguration() [ AbstractFileConfiguration::SERVICE_INIT_CONFIGURATION ] ?? NULL;

        $this->instance = $this->serviceManager->makeServiceInstance($class, $arguments, $config);
    }
535443
public function hasClass($class = null)
    {
        if ($class !== null) {
            $classes = explode(' ', $this->getClass());
            return in_array($class, $classes);
        } else {
            return $this->hasAttribute('class');
        }
    }
771436
public function load($class)
    {
        $class = ltrim($class, '\\');

        if (strpos($class, $this->namespace) === 0) {
            $nsparts = explode('\\', $class);
            $class = array_pop($nsparts);
            $nsparts[ ] = '';
            $path = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts);
            $path .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';

            if (file_exists($path)) {
                require $path;

                return true;
            }
        }

        return false;
    }
636042
public static function autoload($class)
    {
        if (substr($class, -10) == "Controller") {
            self::loadController($class);
        } else if (substr($class, -5) == "Model") {
            self::loadModel($class);
        } else if (substr($class, -6) == "Helper") {
            self::loadHelper($class);
        }
    }
38477
public static function registerModulesClass(string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
            self::$modules_class = $class;
            return true;
        } else {
            return false;
        }
    }
560446
protected static function isMapped($class)
    {
        if (isset(self::$map[$class])) {
            return true;
        }
        if (isset(self::$mapfile) && ! isset(self::$map[$class])) {
            self::$unmapped[] = $class;
            return false;
        }
        return false;
    }
956583
public function loadClass( $class ) {

		//make sure the class name is absolute
		if ( 0 !== strpos( $class, '\\' ) )
			$class = '\\' . $class;

		// check if the namespace matches the class
		if ( 0 !== strpos( $class, $this->base_ns ) )
			return FALSE;

		// strip the base namespace from the beginning of the class name
		if ( $this->base_ns === substr( $class, 0, strlen( $this->base_ns ) ) )
			$class = substr( $class, strlen( $this->base_ns ) );

		$class = ltrim( $class, '\\' );
		$class = str_replace( '\\', '/', $class );
		$file = $this->base_dir . '/' . $class . '.php';

		return $this->file_loader->loadFile( $file );
	}
905960
private static function _autoload($class)
    {
        $realClass = $class;
        if (preg_match('/^JProxy_/i', $class)) {
            $class = preg_replace('/^JProxy_/i', '', $class);
        }
        foreach (self::$prefixes as $prefix => $lookup) {
            $chr = strlen($prefix) < strlen($class) ? $class[strlen($prefix)] : 0;

            if (strpos($class, $prefix) === 0 && ($chr === strtoupper($chr))) {
                $existsBefore = class_exists($realClass, false);
                if ($realClass === $class) {
                    self::loadByAlias($realClass);
                    self::load($realClass);
                }
                $return = true;
                if (!$existsBefore && !class_exists($class, false)) {
                    $return = self::_load(substr($class, strlen($prefix)), $lookup);
                }
                if ($realClass === $class && !$existsBefore && class_exists($realClass, false)) {
                    self::injectStaticDependencies($class);
                }

                return $return;
            }
        }

        return false;
    }
986452
protected function autoload($class) {
		$class=$this->fixslashes(ltrim($class,'\\'));
		/** @var callable $func */
		$func=NULL;
		if (is_array($path=$this->hive['AUTOLOAD']) &&
			isset($path[1]) && is_callable($path[1]))
			list($path,$func)=$path;
		foreach ($this->split($this->hive['PLUGINS'].';'.$path) as $auto)
			if ($func && is_file($file=$func($auto.$class).'.php') ||
				is_file($file=$auto.$class.'.php') ||
				is_file($file=$auto.strtolower($class).'.php') ||
				is_file($file=strtolower($auto.$class).'.php'))
				return require($file);
	}
323772
public function loadClass($class)
    {
        ErrorHandler::stackErrors();

        try {
            if ($this->isFinder) {
                if ($file = $this->classLoader[0]->findFile($class)) {
                    require_once $file;
                }
            } else {
                call_user_func($this->classLoader, $class);
                $file = false;
            }
        } finally {
            ErrorHandler::unstackErrors();
        }

        $exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);

        if ($class && '\\' === $class[0]) {
            $class = substr($class, 1);
        }

        if ($exists) {
            $refl = new \ReflectionClass($class);
            $name = $refl->getName();

            if ($name !== $class && 0 === strcasecmp($name, $class)) {
                throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name));
            }

            $parent = get_parent_class($class);

            // Not an interface nor a trait
            if (class_exists($name, false)) {
                if (preg_match('#\n \* @final(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
                    self::$final[$name] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
                }

                if ($parent && isset(self::$final[$parent])) {
                    @trigger_error(sprintf('The "%s" class is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $parent, self::$final[$parent], $name), E_USER_DEPRECATED);
                }

                // Inherit @final annotations
                self::$finalMethods[$name] = $parent && isset(self::$finalMethods[$parent]) ? self::$finalMethods[$parent] : array();

                foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) {
                    if ($method->class !== $name) {
                        continue;
                    }

                    if ($parent && isset(self::$finalMethods[$parent][$method->name])) {
                        @trigger_error(sprintf('%s It may change without further notice as of its next major version. You should not extend it from "%s".', self::$finalMethods[$parent][$method->name], $name), E_USER_DEPRECATED);
                    }

                    $doc = $method->getDocComment();
                    if (false === $doc || false === strpos($doc, '@final')) {
                        continue;
                    }

                    if (preg_match('#\n\s+\* @final(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
                        $message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
                        self::$finalMethods[$name][$method->name] = sprintf('The "%s::%s()" method is considered final%s.', $name, $method->name, $message);
                    }
                }
            }

            if (in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
                @trigger_error(sprintf('The "%s" class uses the reserved name "%s", it will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
            } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
                self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
            } else {
                // Don't trigger deprecations for classes in the same vendor
                if (2 > $len = 1 + (strpos($name, '\\', 1 + strpos($name, '\\')) ?: strpos($name, '_'))) {
                    $len = 0;
                    $ns = '';
                } else {
                    switch ($ns = substr($name, 0, $len)) {
                        case 'Symfony\Bridge\\':
                        case 'Symfony\Bundle\\':
                        case 'Squire\Component\\':
                            $ns = 'Symfony\\';
                            $len = strlen($ns);
                            break;
                    }
                }

                if (!$parent || strncmp($ns, $parent, $len)) {
                    if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
                        @trigger_error(sprintf('The "%s" class extends "%s" that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
                    }

                    $parentInterfaces = array();
                    $deprecatedInterfaces = array();
                    if ($parent) {
                        foreach (class_implements($parent) as $interface) {
                            $parentInterfaces[$interface] = 1;
                        }
                    }

                    foreach ($refl->getInterfaceNames() as $interface) {
                        if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
                            $deprecatedInterfaces[] = $interface;
                        }
                        foreach (class_implements($interface) as $interface) {
                            $parentInterfaces[$interface] = 1;
                        }
                    }

                    foreach ($deprecatedInterfaces as $interface) {
                        if (!isset($parentInterfaces[$interface])) {
                            @trigger_error(sprintf('The "%s" %s "%s" that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
                        }
                    }
                }
            }
        }

        if ($file) {
            if (!$exists) {
                if (false !== strpos($class, '/')) {
                    throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
                }

                throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
            }
            if (self::$caseCheck) {
                $real = explode('\\', $class.strrchr($file, '.'));
                $tail = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, $file));

                $i = count($tail) - 1;
                $j = count($real) - 1;

                while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
                    --$i;
                    --$j;
                }

                array_splice($tail, 0, $i + 1);
            }
            if (self::$caseCheck && $tail) {
                $tail = DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $tail);
                $tailLen = strlen($tail);
                $real = $refl->getFileName();

                if (2 === self::$caseCheck) {
                    // realpath() on MacOSX doesn't normalize the case of characters

                    $i = 1 + strrpos($real, '/');
                    $file = substr($real, $i);
                    $real = substr($real, 0, $i);

                    if (isset(self::$darwinCache[$real])) {
                        $kDir = $real;
                    } else {
                        $kDir = strtolower($real);

                        if (isset(self::$darwinCache[$kDir])) {
                            $real = self::$darwinCache[$kDir][0];
                        } else {
                            $dir = getcwd();
                            chdir($real);
                            $real = getcwd().'/';
                            chdir($dir);

                            $dir = $real;
                            $k = $kDir;
                            $i = strlen($dir) - 1;
                            while (!isset(self::$darwinCache[$k])) {
                                self::$darwinCache[$k] = array($dir, array());
                                self::$darwinCache[$dir] = &self::$darwinCache[$k];

                                while ('/' !== $dir[--$i]) {
                                }
                                $k = substr($k, 0, ++$i);
                                $dir = substr($dir, 0, $i--);
                            }
                        }
                    }

                    $dirFiles = self::$darwinCache[$kDir][1];

                    if (isset($dirFiles[$file])) {
                        $kFile = $file;
                    } else {
                        $kFile = strtolower($file);

                        if (!isset($dirFiles[$kFile])) {
                            foreach (scandir($real, 2) as $f) {
                                if ('.' !== $f[0]) {
                                    $dirFiles[$f] = $f;
                                    if ($f === $file) {
                                        $kFile = $k = $file;
                                    } elseif ($f !== $k = strtolower($f)) {
                                        $dirFiles[$k] = $f;
                                    }
                                }
                            }
                            self::$darwinCache[$kDir][1] = $dirFiles;
                        }
                    }

                    $real .= $dirFiles[$kFile];
                }

                if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
                  && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
                ) {
                    throw new \RuntimeException(sprintf('Case mismatch between class and real file names: "%s" vs "%s" in "%s".', substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)));
                }
            }

            return true;
        }
    }