getInstance

@param string $name
@param array  ...$args

@return static
349472
public static function getInstance($name, ...$args)
    {
        if (empty(static::$instances[$name])) {
            static::$instances[$name] = new static(...$args);
        }

        return static::$instances[$name];
    }
357057
public static function getInstance(...$args)
    {
        if(static::isChildClassSingleton())
        {
            $className = static::class;
            if(!isset(static::$instances[$className]))
            {
                static::$instances[$className] = new static(...$args);
            }
            return static::$instances[$className];
        }
        else
        {
            if(null === static::$instance)
            {
                static::$instance = new static(...$args);
            }
            return static::$instance;
        }
    }
1153058
public function factory($name, array $args = array())
    {
        foreach ($this->factories as $factory) {
            $command = $factory->factory($name, $args);
            if ($command) {
                return $command;
            }
        }
    }
939667
public function get(string $class_name, array $args = [])
    {
        $class_name = ltrim($class_name, '\\');
        $class_key  = strtolower($class_name);

        if (isset($this->instances[$class_key])) {
            return $this->instances[$class_key];
        }
        if (!isset($this->closures[$class_key])) {
            $this->closures[$class_key] = $this->getClosure($class_name, $class_key);
        }
        return $this->closures[$class_key]($args);
    }
899689
public static function getInstance(string $name = 'default'): self
    {
        if (!isset(self::$instances[$name])) {
            self::setInstance($name, new self());
        }

        return self::$instances[$name];
    }
687328
public static function getInstance($name = 'default')
    {
        if (isset(self::$instance[$name])) {
            return self::$instance[$name];
        }

        $config = Registry::get('config');
        $config = $config['redis'];
        if (!isset($config[$name], $config[$name]['host'])) {
            throw new ConfigException('No redis config!');
        }

        $config = $config[$name];
        $connectType = isset($config['pconnect']) && $config['pconnect'] ? 'pconnect' : 'connect';

        $redis = new self;
        if (!$redis->$connectType(
            $config['host'],
            isset($config['port']) ? $config['port'] : 6379,
            isset($config['timeout']) ? $config['timeout'] : 1
        )) {
            throw new RedisException('Redis server went away!');
        }

        if (isset($config['prefix'])) {
            $redis->setOption(Redis::OPT_PREFIX, $config['prefix']);
        }

        return self::$instance[$name] = $redis;
    }
769140
protected function _instance($name, array $config = []) {
		if ($class = Libraries::locate('command.create', Inflector::camelize($name))) {
			$this->request->params['template'] = $this->template;

			return new $class([
				'request' => $this->request,
				'classes' => $this->_classes
			]);
		}
		return parent::_instance($name, $config);
	}
746064
public function get($name, array $arguments = [])
    {
        if (array_key_exists($name, $this->reflections) === false) {
            throw new RegistryNotFoundException("$name not found registry");
        }

        $reflection = $this->reflections[$name];

        return $reflection->newInstanceArgs($arguments);
    }
805080
public static function getInstance($name)
    {
        if (!isset(static::$instances[$name])) {
            static::$instances[$name] = new CacheInstance();
        }
        return static::$instances[$name];
    }
441290
public static function getInstance(string $name): \Swoole\Atomic
    {
        if(!static::$isInited)
        {
            throw new \RuntimeException('getInstance failed, AtomicManager is not initialized');
        }
        if(!isset(static::$atomics[$name]))
        {
            throw new \RuntimeException(sprintf('GetInstance failed, %s is not found', $name));
        }
        return static::$atomics[$name];
    }
721689
public static function getInstance($name = 'none', $options = array())
	{
		$name = strtolower(preg_replace('/[^A-Z_]/i', '', (string) $name));

		if (empty(self::$instances[$name]))
		{
			$class = __NAMESPACE__ . '\\Storage\\' . ucfirst($name);

			if (!class_exists($class))
			{
				// No attempt to die gracefully here, as it tries to close the non-existing session
				exit('Unable to load session storage class: ' . $name);
			}

			self::$instances[$name] = new $class($options);
		}

		return self::$instances[$name];
	}
1115029
public static function getInstance(string $name)
    {
        if (!isset(self::$instances[$name]) || empty(self::$instances[$name])) {
            new static($name);
        }
        return (self::$instances[$name]);
    }
1111610
public function get(string $name)
    {
        if ($this->isSingleton($name)) {
            /*
             * Object is instantiated as
             * singleton already. Just fetch it.
             */
            return $this->singletonObjects[$name];
        } elseif ($this->isDefined($name)) {
            /*
             * Creates a new instance
             * using map information.
             */
            return $this->build($name);
        } elseif (class_exists($name)) {
            /*
             * Class exists but it is
             * not mapped yet.
             */
            $this->set(
                $name,
                method_exists($name, '__construct') ?
                    $this->generateArgumentsMap($name) : []
            );

            return $this->get($name);
        }

        throw new \Exception("Couldn't create '$name'");
    }
1205123
public static function create($name, ...$args)
    {
        $name = static::getClass($name);

        $class = static::findClass($name);

        if ($class) {
            return static::createObject($class, ...$args);
        }

        return null;
    }
661608
static function factory($name = 'default') {
        $class = get_called_class();
        if (!isset(self::$instances[$class][$name])) {
            self::$instances[$class][$name] = new $class($name);
        }

        return self::$instances[$class][$name];
    }
1219222
protected static function _instance($name = NULL)
	{
		if (!class_exists('Kohana_Database')) {
			throw new ErrorException('Kohana_Database module not loaded');
		}
		$name = static::instanceName($name);

		if (!array_key_exists($name, static::$transactions)) {
			static::$transactions[$name] = FALSE;
		}

		return Kohana_Database::instance($name);
	}
1244829
public function attr($name, $args = [])
    {
        $attr = $this->hasMapping($name) ? $this->getMapping($name) : $name;
        
        if (func_num_args() > 1) {
            return $this->prefix(vsprintf($attr, (array) $args));
        }
        
        return $this->prefix($attr);
    }