Loads the given class or interface.

@param string $class The name of the class

@return bool|null True, if loaded

@throws \RuntimeException
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;
        }
    }
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');
            }
        }
    }
130701
public function loadOne($class = '\\stdClass')
    {
        if (strtolower($class) === 'array') {
            return $this->getReader()->loadArray();
        }

        if (strtolower($class) === 'assoc') {
            return $this->getReader()->loadAssoc();
        }

        return $this->getReader()->loadObject($class);
    }
288640
public static function load($class)
	{
		if (substr($class, 0, strlen(self::PACKAGE)) != self::PACKAGE)
			return false;

		$path = sprintf(
			'%s/%s.php',
			self::$_path,
			str_replace('_', '/', $class)
		);

		if (file_exists($path)) require_once($path);
	}
1172233
public function loadClass($class)
    {
        if (!$file = $this->findFile($class)) {
            return;
        }
        if (!$this->patchable($class)) {
            include $file;
            return true;
        }
        return $this->loadFile($file, $class);
    }
722308
public function loadClass($className) {
		try {
// 			global $AUTOLOADS;
			// PHP's class' names are not case sensitive.
			$bFile = strtolower($className);

			// If the class file path is known in the our array
			if( !empty($this->classes[$bFile]) ) {
				$path	= null;
				$path	= $this->classes[$bFile];
				require_once $path;
				if( !class_exists($className, false) && !interface_exists($className, false) ) {
					throw new \Exception('Wrong use of Autoloads, the class "'.$className.'" should be declared in the given file "'.$path.'". Please use Class Loader correctly.');
				}
			}
		} catch( Exception $e ) {
			log_error($e, 'loading_class_'.$className);
		}
	}
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);
    }
706263
protected static function _initialize($class) {
		$self = parent::_initialize($class);
		if (!$self->_inited) {
			$self->_inited = true;
			$self->_init();
		}
		return $self;
	}
69753
public function get(string $class)
    {
        if (isset($this->instantiated[$class]) && $this->shared[$class]) {
            return $this->instantiated[$class];
        }

        $args = $this->services[$class];

        switch (count($args)) {
            case 0:
                $object = new $class();
                break;
            case 1:
                $object = new $class($args[0]);
                break;
            case 2:
                $object = new $class($args[0], $args[1]);
                break;
            case 3:
                $object = new $class($args[0], $args[1], $args[2]);
                break;
            default:
                throw new \OutOfRangeException('Too many arguments given');
        }

        if ($this->shared[$class]) {
            $this->instantiated[$class] = $object;
        }

        return $object;
    }
184111
private function loadCachedClass($class)
    {
        $result = false;

        if (isset($this->cache[$class])) {
            $result = include $this->cache[$class];

            if ($result === false) {
                unset($this->cache[$class]);
                $this->saveCache();
            }
        }

        return $result !== false;
    }
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;
    }
130739
public function loadClass($className) {
        $cache = $this->getCache();
        $entries = $cache->load($this->cacheKey);
        if($entries == false) {
            $entries = array();
        }
        $status = $this->tryAndLoadClass($className, $entries);
        if($status) {
            // class loaded
            return true;
        }
        if(preg_match($this->ignoreClassNamesRegexp, $className)) {
            return false;
        }
 
        foreach($this->classPaths as $path) {
            // Scan for file
            $realPath = $this->searchForClassFile($className, $path);
            if($realPath !== false) {
                $entries[$className] = $realPath;
                break;
            }
        }
        $cache->save($entries, $this->cacheKey);
        $status = $this->tryAndLoadClass($className, $entries);
        return $status;
    }
204280
private function loadFilter($class)
    {
        if (isset($this->filtersInstances[$class])) {
            return true;
        }

        $filter = $this->objectsFactory->buildFilter($class, $this->loadedConfigurator);

        if ($filter === false) {
            $this->loadedLogger->warning('Could not load ' . $class . ' filter.');

            return false;
        }

        $this->filtersInstances[$class] = $filter;
        $this->loadedLogger->debug('Filter ' . $class . ' found & loaded.');

        return true;
    }
724489
public static function onAutoLoad($class)
    {
        if (isset(self::$customMappings[$class])) {
            require_once(self::$customMappings[$class]);

            return true;
        }

        if (self::$_namespaces !== null) {
            foreach (self::$_namespaces as $data) {
                $ns = $data[0];

                $nsl = $data[2];


                if (substr($class, 0, $nsl) !== $ns) {
                    continue;
                }

                $dir = $data[1];
                $ext = $data[3];

                $file = $dir . str_replace('\\', '/', substr($class, $nsl)) . $ext;

                if (is_file($file)) {
                    require_once($file);

                    return true;
                }
            }
        }

        return false;
    }
1311944
private function loadCommand($class) {
        $controller = new $class();
        if (!is_a($controller, '\\mpf\\cli\\Command')) {
            $this->critical('Command `' . $class . '` must extend \\mpf\\cli\\Command!', array(
                'requestedController' => $this->request()->getController(),
                'requestedModule' => $this->request()->getModule()
            ));
            return null;
        }
        return $controller;
    }
606194
public static function load($class)
    {
        $class = static::normalizeClass($class);

        foreach (static::$directories as $directory)
        {
            if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$class))
            {
                require_once $path;

                return true;
            }
        }
        return false;
    }
768374
public function load( $class ) {

    // do not import class that is exists already
    if( static::exist( $class ) ) return true;
    else {

      // fix for absolute class definitions
      $class = ltrim( $class, '\\' );

      $path = explode( '\\', $class );
      $name = array_pop( $path );

      // try first the custom paths (custom autoload path support)
      foreach( $this->definition as $namespace => list( $directory, $length ) ) {
        if( strpos( $class, $namespace ) === 0 ) {

          // return when the loader find a perfect match, and the class really exist
          if( $this->search( $name, array_slice( $path, $length ), $directory ) && static::exist( $class ) ) {
            return true;
          }
        }
      }

      return false;
    }
  }