Automattic\WooCommerce\Vendor\League\Container

ReflectionContainer::get()publicWC 1.0

{@inheritdoc}

Method of the class: ReflectionContainer{}

No Hooks.

Return

null. Nothing (null).

Usage

$ReflectionContainer = new ReflectionContainer();
$ReflectionContainer->get( $id, $args );
$id (required)
-
$args(array)
-
Default: []

ReflectionContainer::get() code WC 8.7.0

public function get($id, array $args = [])
{
    if ($this->cacheResolutions === true && array_key_exists($id, $this->cache)) {
        return $this->cache[$id];
    }

    if (! $this->has($id)) {
        throw new NotFoundException(
            sprintf('Alias (%s) is not an existing class and therefore cannot be resolved', $id)
        );
    }

    $reflector = new ReflectionClass($id);
    $construct = $reflector->getConstructor();

    $resolution = $construct === null
        ? new $id
        : $resolution = $reflector->newInstanceArgs($this->reflectArguments($construct, $args))
    ;

    if ($this->cacheResolutions === true) {
        $this->cache[$id] = $resolution;
    }

    return $resolution;
}