src/Leevel/Di/Container.php
public function instance($name, $service = null): IContainer
    {
        if (is_array($name)) {
            list($name, $alias) = $this->parseAlias($name);
            $this->alias($name, $alias);
        }

        if (null === $service) {
            $service = $name;
        }

        if ($this->coroutineContext($service)) {
            $this->coroutineInstances[$this->coroutineUid()][$name] = $service;
        } else {
            $this->instances[$name] = $service;
        }

        return $this;
    }
public function instance($name, $service = null): IContainer
    {
        if (is_array($name)) {
            list($name, $alias) = $this->parseAlias($name);
            $this->alias($name, $alias);
        }

        if (null === $service) {
            $service = $name;
        }

        if ($this->coroutineContext($service)) {
            $this->coroutineInstances[$this->coroutineUid()][$name] = $service;
        } else {
            $this->instances[$name] = $service;
        }

        return $this;
    }
注册为实例.

@param mixed $name
@param mixed $service

@return $this