Register an existing instance as shared in the container.

@param  string  $abstract
@param  mixed   $instance

@return void
177003
public function instance($abstract, $instance)
    {
        $abstract = $this->normalize($abstract);
        if (is_array($abstract)) {
            list($abstract, $alias) = $this->extractAlias($abstract);
            $this->alias($abstract, $alias);
        }
        unset($this->aliases[$abstract]);
        $bound = $this->bound($abstract);

        $this->instances[$abstract] = $instance;
        if ($bound) {
            $this->rebound($abstract);
        }
    }
1161212
public static function setInstance($instance)
    {
        if ($instance === null) {
            unset(Yii::getApp()->loadedModules[static::class]);
        } else {
            Yii::getApp()->loadedModules[\get_class($instance)] = $instance;
        }
    }
980780
public function replaceInstance(string $hint, object $instance): void
	{
		$hint = $this->resolveAlias($hint);

		if(!isset($this->instances[$hint]))
		{
			throw new ContainerException(vsprintf('Unable to replace [ %s ] as it hasn\'t been registered.', [$hint]));
		}

		$this->instances[$hint] = $instance;

		$this->replaceInstances($hint);
	}
1211900
public function register(Container $container)
    {
        $container->prepareSharedObject(CoreLanguage::class)
            ->bindShared(Language::class, CoreLanguage::class)
            ->bindShared(LanguageInterface::class, CoreLanguage::class);
    }
1220454
public function bind(string $abstract, $concrete = null, array $arguments = []): self
    {
        $this->data->bind($abstract, $concrete, $arguments);

        return $this;
    }
1271486
protected function callAllListeners($abstract, $instance)
    {
        $this->callListeners($abstract, $instance, $this->resolvingListeners);
        $this->callListeners($abstract, $instance, $this->resolvedListeners);
    }
1351037
public function setAccount(AbstractAccount $account)
    {
        if ($this->isTransacted() || $this->parent) {
            return;
        }

        $this->account = $account;
    }
518368
public static function set($className, $instance)
    {
        $key = self::getStorageKey($className);

        if (is_null($instance)) {
            unset(self::$instances[$key]);

            return;
        }

        self::$instances[$key] = $instance;

        return;
    }
755575
public function registerInstance($hint, object $instance): void
	{
		$this->instances[$this->parseHint($hint)] = $instance;
	}
605894
public function isShared($abstract)
    {
        return isset($this->instances[$abstract]) ||
               (isset($this->bindings[$abstract]['shared']) &&
               $this->bindings[$abstract]['shared'] === true);
    }
392590
public function extend($abstract, Closure $closure)
    {
        $abstract = $this->getAlias($abstract);

        if (isset($this->instances[$abstract])) {
            $this->instances[$abstract] = $closure($this->instances[$abstract], $this);

            $this->rebound($abstract);
        } else {
            $this->extenders[$abstract][] = $closure;

            if ($this->resolved($abstract)) {
                $this->rebound($abstract);
            }
        }
    }
374755
public function setInstance($instance) {
		$reflection = new ReflectionClass($instance);
		$name = str_replace('\\', ':', $reflection->getName());
		$this->instances[$name] = $instance;
	}
163857
public static void register(String name, Object instance) {
    try {
      Class<Object> mbeanInterface = guessMBeanInterface(instance);
      ManagementFactory.getPlatformMBeanServer().registerMBean(new StandardMBean(instance, mbeanInterface), new ObjectName(name));

    } catch (MalformedObjectNameException | NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
      throw new IllegalStateException("Can not register MBean [" + name + "]", e);
    }
  }
122647
public function isShared($abstract)
    {
        if (isset($this->bindings[$abstract]['shared'])) {
            $shared = $this->bindings[$abstract]['shared'];
        } else {
            $shared = false;
        }

        return isset($this->instances[$abstract]) || $shared === true;
    }
719474
public function register($cubeClassName, array &$definitions)
    {
        if (!isset($this->registered[$cubeClassName])) {
            $cube = new $cubeClassName;
            if (!$cube instanceof AbstractCube) {
                throw new CubeException($cubeClassName . ' is not an instance of ' . AbstractCube::class);
            }

            if ($cube->enabled) {
                $cube->registerDependencies($definitions);
                $this->registered[$cubeClassName] = $cube;
            }
        }
    }
435074
public function register(Container $container)
    {
        $container->share(Container::class, $container);

        $container->share(get_class($this->app), $this->app)
            ->bindShared(WindwalkerApplicationInterface::class, get_class($this->app));

        $container->share(Config::class, $this->config);

        $container->prepareSharedObject(PackageResolver::class);

        $this->registerClassAlias();
    }
316963
public function registerArray(array $instances)
    {
        foreach ($instances as $name => $instance) {
            $this->register($name, $instance);
        }

        return $this;
    }