0 follower

Final Class Yiisoft\Yii\Debug\Collector\ContainerInterfaceProxy

InheritanceYiisoft\Yii\Debug\Collector\ContainerInterfaceProxy
ImplementsPsr\Container\ContainerInterface
Uses TraitsYiisoft\Proxy\ProxyTrait, Yiisoft\Yii\Debug\Collector\ProxyLogTrait, Yiisoft\Yii\Debug\ProxyDecoratedCalls

Protected Properties

Hide inherited properties

Property Type Description Defined By
$decorated \Psr\Container\ContainerInterface Yiisoft\Yii\Debug\Collector\ContainerInterfaceProxy

Protected Methods

Hide inherited methods

Method Description Defined By
logProxy() Yiisoft\Yii\Debug\Collector\ProxyLogTrait

Property Details

Hide inherited properties

$decorated protected property
protected \Psr\Container\ContainerInterface $decorated null

Method Details

Hide inherited methods

__call() public method
public mixed __call ( string $name, array $arguments )
$name string
$arguments array

                public function __call(string $name, array $arguments)
{
    /**
     * @psalm-suppress MixedMethodCall
     */
    return $this->decorated->$name(...$arguments);
}

            
__construct() public method

public mixed __construct ( \Psr\Container\ContainerInterface $decorated, Yiisoft\Yii\Debug\Collector\ContainerProxyConfig $config )
$decorated \Psr\Container\ContainerInterface
$config Yiisoft\Yii\Debug\Collector\ContainerProxyConfig

                public function __construct(
    protected ContainerInterface $decorated,
    ContainerProxyConfig $config,
) {
    $this->config = $config;
    $this->proxyManager = new ProxyManager($this->config->getProxyCachePath());
}

            
__get() public method
public mixed __get ( string $name )
$name string

                public function __get(string $name)
{
    return $this->decorated->$name;
}

            
__set() public method
public void __set ( string $name, mixed $value )
$name string
$value mixed

                public function __set(string $name, mixed $value): void
{
    $this->decorated->$name = $value;
}

            
get() public method

public mixed get ( mixed $id )
$id mixed

                public function get($id): mixed
{
    $this->resetCurrentError();
    $timeStart = microtime(true);
    $instance = null;
    try {
        $instance = $this->getInstance($id);
    } catch (ContainerExceptionInterface $e) {
        $this->repeatError($e);
    } finally {
        $this->logProxy(ContainerInterface::class, $this->decorated, 'get', [$id], $instance, $timeStart);
    }
    if (
        is_object($instance)
        && (
            ($proxy = $this->getServiceProxyCache($id)) ||
            ($proxy = $this->getServiceProxy($id, $instance))
        )
    ) {
        $this->setServiceProxyCache($id, $proxy);
        return $proxy;
    }
    return $instance;
}

            
has() public method

public boolean has ( mixed $id )
$id mixed

                public function has($id): bool
{
    $this->resetCurrentError();
    $timeStart = microtime(true);
    $result = null;
    try {
        $result = $this->decorated->has($id);
    } catch (ContainerExceptionInterface $e) {
        $this->repeatError($e);
    } finally {
        $this->logProxy(ContainerInterface::class, $this->decorated, 'has', [$id], $result, $timeStart);
    }
    return (bool)$result;
}

            
isActive() public method

public boolean isActive ( )

                public function isActive(): bool
{
    return $this->config->getIsActive() && $this->config->getDecoratedServices() !== [];
}

            
logProxy() protected method
protected void logProxy ( string $service, object $instance, string $method, array $arguments, mixed $result, float $timeStart )
$service string
$instance object
$method string
$arguments array
$result mixed
$timeStart float

                protected function logProxy(
    string $service,
    object $instance,
    string $method,
    array $arguments,
    mixed $result,
    float $timeStart
): void {
    $error = $this->getCurrentError();
    $this->processLogData($arguments, $result, $error);
    if ($this->config->getCollector() !== null) {
        $this->logToCollector($service, $instance, $method, $arguments, $result, $error, $timeStart);
    }
    if ($this->config->getDispatcher() !== null) {
        $this->logToEvent($service, $instance, $method, $arguments, $result, $error, $timeStart);
    }
}

            
withDecoratedServices() public method

public self withDecoratedServices ( array $decoratedServices )
$decoratedServices array

                public function withDecoratedServices(array $decoratedServices): self
{
    $new = clone $this;
    $new->config = $this->config->withDecoratedServices($decoratedServices);
    return $new;
}