src/Container.php
function share(string $id, \Closure $value)
    {
        $this->entries[$id] = function ($container) use ($value) {
            static $resolvedValue;
            if (is_null($resolvedValue)) {
                $resolvedValue = $value($container);
            }
            return $resolvedValue;
        };
    }
function share(string $id, \Closure $value)
    {
        $this->entries[$id] = function ($container) use ($value) {
            static $resolvedValue;
            if (is_null($resolvedValue)) {
                $resolvedValue = $value($container);
            }
            return $resolvedValue;
        };
    }
Adds a shared (singleton) entry to the container.
@param string $id Identifier of the entry.
@param \Closure $value The closure to invoke when this entry is resolved.