src/WorkerF/IOCContainer.php
public static function singleton($instance, $name = NULL)
    {
        if ( ! is_object($instance)) {
            throw new \InvalidArgumentException("Object need!");
        }

        $class_name = $name == NULL ? get_class($instance) : $name;

        // singleton not exist, create
        if ( ! array_key_exists($class_name, self::$_singleton)) {
            self::$_singleton[$class_name] = $instance;
        }
    }
public static function singleton($instance, $name = NULL)
    {
        if ( ! is_object($instance)) {
            throw new \InvalidArgumentException("Object need!");
        }

        $class_name = $name == NULL ? get_class($instance) : $name;

        // singleton not exist, create
        if ( ! array_key_exists($class_name, self::$_singleton)) {
            self::$_singleton[$class_name] = $instance;
        }
    }
set a singleton instance.

@param  object $instance
@param  string $name
@return void
@throws \InvalidArgumentException