src/Container/Container.php
public function ref(string $name)
    {
        if (isset($this->active[$name])) {
            return $this->values[$name];
        }

        return function () use ($name) {
            return $this->get($name);
        };
    }
public function ref(string $name)
    {
        if (isset($this->active[$name])) {
            return $this->values[$name];
        }

        return function () use ($name) {
            return $this->get($name);
        };
    }
public function ref ( string $ name ) { if ( isset ( $ this -> active [ $ name ] ) ) { return $ this -> values [ $ name ] ; } return function ( ) use ( $ name ) { return $ this -> get ( $ name ) ; } ; }
Creates a boxed reference to a component with a given name.

You can use this in conjunction with `register()` to provide a component reference
without expanding that reference until first use - for example:

$container->register(UserRepo::class, [$container->ref('cache')]);

This will reference the "cache" component and provide it as the first argument to the
constructor of `UserRepo` - compared with using `$container->get('cache')`, this has
the advantage of not actually activating the "cache" component until `UserRepo` is
used for the first time.

Another reason (besides performance) to use references, is to defer the reference:

$container->register(FileCache::class, ['root_path' => $container->ref('cache.path')]);

In this example, the component "cache.path" will be fetched from the container on
first use of `FileCache`, giving you a chance to configure "cache.path" later.

@param string $name component name

@return mixed|\Closure component reference
Creates a boxed reference to a component with a given name .