Automattic\WooCommerce\Vendor\League\Container

ReflectionContainer::get()publicWC 1.0

{@inheritdoc}

Метод класса: ReflectionContainer{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ReflectionContainer = new ReflectionContainer();
$ReflectionContainer->get( $id, $args );
$id (обязательный)
-
$args(массив)
-
По умолчанию: []

Код ReflectionContainer::get() 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;
}