src/FACTFinder/Loader.php
public static function getInstance($name)
    {
        if (isset(self::$classNames[$name]))
        {
            $className = self::$classNames[$name];
        }
        else
        {
            $className = self::getClassName($name);
            self::$classNames[$name] = $className;
        }

        // this snippet is from the typo3 class "t3lib_div"
        // written by Kasper Skaarhoj <kasperYYYY@typo3.com>
        if (func_num_args() > 1)
        {
            // getting the constructor arguments by removing this
            // method's first argument (the class name)
            $constructorArguments = func_get_args();
            array_shift($constructorArguments);

            $reflectedClass = new \ReflectionClass($className);
            $instance = $reflectedClass->newInstanceArgs($constructorArguments);
        }
        else
        {
            $instance = new $className;
        }

        return $instance;
    }
public static function getInstance($name)
    {
        if (isset(self::$classNames[$name]))
        {
            $className = self::$classNames[$name];
        }
        else
        {
            $className = self::getClassName($name);
            self::$classNames[$name] = $className;
        }

        // this snippet is from the typo3 class "t3lib_div"
        // written by Kasper Skaarhoj <kasperYYYY@typo3.com>
        if (func_num_args() > 1)
        {
            // getting the constructor arguments by removing this
            // method's first argument (the class name)
            $constructorArguments = func_get_args();
            array_shift($constructorArguments);

            $reflectedClass = new \ReflectionClass($className);
            $instance = $reflectedClass->newInstanceArgs($constructorArguments);
        }
        else
        {
            $instance = new $className;
        }

        return $instance;
    }
Creates an instance of a class taking into account classes within the
"FACTFinder\Custom\" namespace instead of "FACTFinder\".
Note that classes in the \Custom namespace should inherit the class they
overwrite - otherwise some of the type hinting within the library might
break.
USE THIS method instead of the PHP "new" keyword for all classes from
this library.
Eg. instead of "$obj = new myclass;", you should use
"$obj = FACTFinder\Loader::getInstance("myclass")"!
You can also pass arguments for a constructor:
Loader::getInstance('myClass', $arg1, $arg2,  ..., $argN)

@param    string $name   Class name to instantiate
@param    mixed optional Constructor parameters
@return   object         A reference to the instance