Auto-load classes on demand to reduce memory consumption. Classes must have a namespace so as to resolve
performance issues around auto-loading classes unrelated to current plugin.

@param string $class The name of the class object.
769042
public function autoload( $class ) {
		$parent               = explode( '\\', get_class( $this ) );
		$class_array          = explode( '\\', $class );
		$intersect            = array_intersect_assoc( $parent, $class_array );
		$intersect_depth      = count( $intersect );
		$autoload_match_depth = static::$autoload_ns_match_depth;
		// Confirm $class is in same namespace as this autoloader.
		if ( $intersect_depth >= $autoload_match_depth ) {
			$file = $this->get_file_name_from_class( $class );
			if ( 'classmap' === static::$autoload_type && is_array( $this->autoload_dir ) ) {
				foreach ( $this->autoload_dir as $dir ) {
					$this->load_file( $this->installed_dir . $dir . $file );
				}
			} else {
				$this->load_file( $this->installed_dir . $file );
			}
		}

	}
1316837
public static function load($class)
    {
        // Get just class name without ns
        $className = self::getOnlyClass($class);
        // Get just ns without class name
        $nameSpace = self::getOnlyNameSpace($class);

        // If this is not core class
        if ($nameSpace != __NAMESPACE__) {
            // Convert namespace to base directory add class
            $path = __SAMSON_VENDOR_PATH . str_replace('\\', DIRECTORY_SEPARATOR, $nameSpace) . DIRECTORY_SEPARATOR . $className . '.php';

            // Load class by file name
            if (file_exists($path)) {
                //elapsed('Autoloading class '.$class.' at '.$path);
                require_once($path);
                // old school compatibility will be removed when old modules will be updated
            } else if (self::oldModule($className, $nameSpace, $path)) {
                //elapsed('Autoloading(old style) class '.$class.' at '.$path);
                require_once($path);
                // Handle old module loading
            } else { // Signal error
                return e('Class name ## not found', E_SAMSON_CORE_ERROR, $class);
            }

        } else { // Load core classes separately using this class location
            require_once(__DIR__ . '/' . $className . '.php');
        }

        return true;
    }
342911
public function autoload( $class ) {
		$ClassArray = explode( '\\', $class );

		if ( count( $ClassArray ) > 1 ) {

			if ( php_sapi_name() == 'cli' ) {
				$MvcPath = $this->config->get( 'path.basepath' ) . $this->config->get( 'path.mvc' );
			} else {
				$MvcPath = $this->config->get( 'path.mvc' );
			}

			//** if count $ClassArray = 3 is HMVC
			if ( count( $ClassArray ) >= 3 ) {
				$HmvcPath = '';

				for ( $i = 0; $i < count( $ClassArray ) - 2; $i ++ ) {
					$HmvcPath .= $ClassArray[ $i ] . '/';
				}

				//**        MVC Path    /     Module     Controllers/Models                         /    Class.php
				$FileLoad = $MvcPath . '/' . $HmvcPath . $ClassArray[ count( $ClassArray ) - 2 ] . '/' . $ClassArray[ count( $ClassArray ) - 1 ] . '.php';
			} else {
				//**        MVC Path    /    Controller/Models /    Class.php
				$FileLoad = $MvcPath . '/' . $ClassArray[0] . '/' . $ClassArray[1] . '.php';
			}

			if ( file_exists( $FileLoad ) ) {
				include $FileLoad;
			}

		}

	}
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;
    }
634220
public function loadClass($class)
    {
        $result = $this->loadCachedClass($class);

        if ($result === false) {
            $result = parent::loadClass($class);
        }

        if ($this->verbose) {
            return $result !== false;
        }
    }
97170
public function loadClass($class)
    {
        if ($file = $this->classFinder->findFile($class)) {
            require $file;

            if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
                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));
            }

            return true;
        }
    }
642408
public function loadClass($class)
    {
        if (strpos($class, self::ANNOTATION_NAMESPACE) === 0) {
            $class = str_replace(self::ANNOTATION_NAMESPACE, '', $class);

            $file = __DIR__ . '/' . $class . '.php';
            if (file_exists($file)) {
                require_once $file;

                return true;
            }
        }
    }
1161947
static public function autoload($classname)
    {
        if (strpos($classname, __NAMESPACE__) === 0) {
            $classname = substr($classname, strlen(__NAMESPACE__) + 1);
            if (file_exists(__DIR__ . '/' . str_replace('\\', '/', $classname) . '.php')) {
                require_once __DIR__ . '/' . str_replace('\\', '/', $classname) . '.php';
            }
        }
    }
318954
public function setClass($class)
    {
        foreach ($this->results as $name) {
            $this->columns->offsetGet($name)->setClass($class);
        }
    }
1003685
protected function addClass(string $class)
    {
        if ($this->initialized) {
            throw new RuntimeException("You can't register provider class as registry as been initialized.");
        }

        if (!class_exists($class)) {
            throw new InvalidArgumentException("Class $class does not exist.");
        }

        if (!is_subclass_of($class, ProviderInterface::class)) {
            throw new InvalidArgumentException("Class $class must implement " . ProviderInterface::class);
        }

        $this->classes[] = $class;
    }
604299
public function autoload( $class ) {

		// Iterate over namespaces to find a match.
		foreach ( $this->namespaces as $namespace ) {

			// Move on if the object does not belong to the current namespace.
			if ( 0 !== strpos( $class, $namespace['root'] ) ) {
				continue;
			}

			// Remove namespace root level to correspond with root filesystem, and
			// replace the namespace separator "\" by the system-dependent directory separator.
			$filename = str_replace(
				array( $namespace['root'], '\\' ),
				array( '', DIRECTORY_SEPARATOR ),
				$class
			);

			// Remove a leading backslash from the class name.
			$filename = $this->remove_leading_backslash( $filename );

			// Change to lower case if requested.
			if ( $namespace['lowercase'] ) {
				$filename = strtolower( $filename );
			}

			// Change underscores into hyphens if requested.
			if ( $namespace['underscores'] ) {
				$filename = str_replace( '_', '-', $filename );
			}

			// Add base_dir, prefix and suffix.
			$filepath = $namespace['base_dir']
				. $namespace['prefix']
				. $filename
				. $namespace['suffix'];

			// Throw an exception if the file does not exist or is not readable.
			if ( is_readable( $filepath ) ) {
				require_once $filepath;
			}
		}
	}
1018364
public static function loadByAlias($class)
    {
        if (!isset(self::$classAliases[$class])) {
            foreach (self::$classAliases as $key => $value) {
                if (strlen($key) == strlen($class) && false !== stripos($key, $class)) {
                    $class = $key;
                    break;
                }
            }
        }

        $existsBefore = class_exists($class, false);
        $success = parent::loadByAlias($class);
        if (!$existsBefore && class_exists($class, false)) {
            self::injectStaticDependencies($class);
        }

        return $success;
    }
180599
public function loadClass($class)
    {
        foreach (spl_autoload_functions() as $func) {
            if (is_array($func) && $func[0] === $this) {
                continue;
            }
            $this->classList->push($class);
            if (call_user_func($func, $class)) {
                break;
            }
        }

        $this->classList->next();

        return true;
    }
677051
public static function classAutoLoader(string $class)
    {
        self::ensureDefines();
        
        $coreBaseNamespace = str_replace('\\', '/', __NAMESPACE__) . '/';
        
        $classWithNamespaceToLoad = str_replace('\\', '/', $class);
        $classWithRelativeNamespaceToLoad = str_replace($coreBaseNamespace, '', $classWithNamespaceToLoad);
        
        $namespaceToLoad = dirname($classWithNamespaceToLoad);
        $classToLoad = basename($classWithNamespaceToLoad);
        
        $classFileName = $classToLoad . EXT_PHP;
        
        $paths = array();
        
        $possibleParentConstants = array(
            Xentriq::CONST_DIR_CORE, // core directory
            Xentriq::CONST_DIR_LIBS, // libraries directory
            Xentriq::CONST_DIR_ADDONS, // addon directory
            Xentriq::CONST_DIR_ASSUMED_ROOT // assumed root directory
        );
        
        foreach ($possibleParentConstants as $possibleParentConstant) {
            // search core directory
            if (defined($possibleParentConstant)) {
                $parentPath = constant($possibleParentConstant);
                
                $paths[] = ($parentPath . '/' . $classFileName);
                $paths[] = ($parentPath . $classWithNamespaceToLoad . EXT_PHP);
                $paths[] = ($parentPath . strtolower(dirname($classWithRelativeNamespaceToLoad)) . '/' . $classFileName);
                
                // search paths with hyphen
                $segments = explode('/', $namespaceToLoad);
                
                for ($sidx = 1; $sidx <= (sizeof($segments)); $sidx++) {
                    $baseHyphenPath = implode('-', array_slice($segments, 0, $sidx));
                    $completeHyphenPath = $baseHyphenPath . CHAR_SLASH . implode('/', array_slice($segments, $sidx));
                    
                    $paths[] = ($parentPath . $baseHyphenPath . '/' . $classFileName);
                    $paths[] = ($parentPath . $completeHyphenPath . '/' . $classFileName);
                    $paths[] = ($parentPath . strtolower($baseHyphenPath) . '/' . $classFileName);
                    $paths[] = ($parentPath . strtolower($completeHyphenPath) . '/' . $classFileName);
                }
            }
        }
        
        foreach ($paths as $path) {
            if (is_file($path) && !class_exists($path)) {
                require_once $path;
                
                // exit loader
                return;
            }
        }
        
        // search in addons
        $classFile = Addons::searchAddonClassFile($class);
        if (is_file($classFile)) {
            require_once $classFile;
        }
    }
701075
public static function load($class)
    {
        if (stripos($class, 'Phpass') === 0) {
            $file = str_replace('\\', '/', $class);

            if (file_exists(dirname(__FILE__) . '/../' . $file . '.php')) {
                require_once(dirname(__FILE__) . '/../' . $file . '.php');
            }
        }
    }
921233
protected static function loadMappings(/*# string */ $class)
    {
        // mapping status changed ?
        if (self::isStatusUpdated()) {
            self::resetMappings();
            self::setStatus(false);
        }

        // $class' mapping loaded already
        if ($class::hasMappings()) {
            return;
        }

        // load $class mapping
        $loadedClass = $class::hasLoader();
        if ($loadedClass) {
            // loader found
            $class::setMappings(
                $loadedClass::getLoader()->loadMessages($class)
            );
        } else {
            // no loader found
            $class::setMappings([]);
        }
    }
793392
public function loadClass(string $class): ?bool
    {
        if ($file = $this->findFile($class)) {
            _includeClassFile($file);
            return true;
        }

        return null;
    }