createProxy example

/** * Gets the public 'foo' service. * * @return \Bar\FooLazyClass */
    protected static function getFooService($container$lazyLoad = true)
    {
        $container->factories['foo'] ??= fn () => self::getFooService($container);

        if (true === $lazyLoad) {
            return $container->createProxy('FooLazyClassGhost2108fce', static fn () => \FooLazyClassGhost2108fce::createLazyGhost(static fn ($proxy) => self::getFooService($container$proxy)));
        }

        static $include = true;

        if ($include) {
            include_once __DIR__.'/Fixtures/includes/foo_lazy.php';

            $include = false;
        }

        return $lazyLoad;
    }
/** * Gets the private 'foo' service. * * @return \stdClass */
    protected static function getFooService($container$lazyLoad = true)
    {
        $container->factories['service_container']['foo'] ??= self::getFooService(...);

        if (true === $lazyLoad) {
            return $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getFooService($container$proxy)));
        }

        return $lazyLoad;
    }
}

class stdClassGhost2fc7938 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface
{
    use \Symfony\Component\VarExporter\LazyGhostTrait;

    private const LAZY_OBJECT_PROPERTY_SCOPES = [];
}
return $container->services['foo'] = new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo();
    }

    /** * Gets the private '.lazy.Symfony\Component\DependencyInjection\Tests\Compiler\Foo' shared service. * * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Foo */
    protected static function getFoo2Service($container$lazyLoad = true)
    {
        if (true === $lazyLoad) {
            return $container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] = $container->createProxy('FooProxy4048957', static fn () => \FooProxy4048957::createLazyProxy(static fn () => self::getFoo2Service($container, false)));
        }

        return ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo());
    }
}

class FooProxy4048957 extends \Symfony\Component\DependencyInjection\Tests\Compiler\Foo implements \Symfony\Component\VarExporter\LazyObjectInterface
{
    use \Symfony\Component\VarExporter\LazyProxyTrait;

    private const LAZY_OBJECT_PROPERTY_SCOPES = [];
}
/** * Gets the public 'wither' autowired service. * * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Wither */
    protected static function getWitherService($container$lazyLoad = true)
    {
        $container->factories['wither'] ??= fn () => self::getWitherService($container);

        if (true === $lazyLoad) {
            return $container->createProxy('WitherProxyDd381be', static fn () => \WitherProxyDd381be::createLazyProxy(static fn () => self::getWitherService($container, false)));
        }

        $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither();

        $a = ($container->privates['Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo());

        $instance = $instance->withFoo1($a);
        $instance = $instance->withFoo2($a);
        $instance->setFoo($a);

        return $instance;
    }

return new class
D
    public $proxyClass;
    private $privates = [];

    public function getFooService($lazyLoad = true)
    {
        $container = $this;

        if (true === $lazyLoad) {
            return $container->privates['foo'] = $container->createProxy('SunnyInterface_1eff735', static fn () => \SunnyInterface_1eff735::staticProxyConstructor(
                static function D&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
                    $wrappedInstance = $container->getFooService(false);

                    $proxy->setProxyInitializer(null);

                    return true;
                }
            ));
        }

        return new Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyClass();
    }
return $factory();
    }

    /** * Gets the public 'bar' shared service. * * @return \stdClass */
    protected static function getBarService($container$lazyLoad = true)
    {
        if (true === $lazyLoad) {
            return $container->services['bar'] = $container->createProxy('stdClassGhost2fc7938', static fn () => \stdClassGhost2fc7938::createLazyGhost(static fn ($proxy) => self::getBarService($container$proxy)));
        }

        return $lazyLoad;
    }

    /** * Gets the public 'baz' shared service. * * @return \stdClass */
    protected static function getBazService($container$lazyLoad = true)
    {
return $container->services['foo'] = new \Symfony\Component\DependencyInjection\Tests\Compiler\AAndIInterfaceConsumer($a);
    }

    /** * Gets the private '.lazy.foo.gDmfket' shared service. * * @return \object */
    protected static function get_Lazy_Foo_GDmfketService($container$lazyLoad = true)
    {
        if (true === $lazyLoad) {
            return $container->privates['.lazy.foo.gDmfket'] = $container->createProxy('objectProxy8ac8e9a', static fn () => \objectProxy8ac8e9a::createLazyProxy(static fn () => self::get_Lazy_Foo_GDmfketService($container, false)));
        }

        return ($container->services['foo'] ?? self::getFooService($container));
    }
}

class objectProxy8ac8e9a implements \Symfony\Component\DependencyInjection\Tests\Compiler\AInterface, \Symfony\Component\DependencyInjection\Tests\Compiler\IInterface, \Symfony\Component\VarExporter\LazyObjectInterface
{
    use \Symfony\Component\VarExporter\LazyProxyTrait;

    private const LAZY_OBJECT_PROPERTY_SCOPES = [];

    
$factory = new class($this->config, $this->generator) extends LazyLoadingValueHolderFactory {
            use LazyLoadingFactoryTrait;
        };

        $initializer = static function D&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
            $wrappedInstance = $realInstantiator();
            $proxy->setProxyInitializer(null);

            return true;
        };

        return $factory->createProxy($proxifiedClass->name, $initializer[
            'fluentSafe' => $definition->hasTag('proxy'),
            'skipDestructor' => true,
        ]);
    }
}
return $factory();
    }

    /** * Gets the public 'wither' shared autowired service. * * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Wither */
    protected static function getWitherService($container$lazyLoad = true)
    {
        if (true === $lazyLoad) {
            return $container->services['wither'] = $container->createProxy('WitherProxy580fe0f', static fn () => \WitherProxy580fe0f::createLazyProxy(static fn () => self::getWitherService($container, false)));
        }

        $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither();

        $a = new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo();

        $instance = $instance->withFoo1($a);
        $instance = $instance->withFoo2($a);
        $instance->setFoo($a);

        return $instance;
    }
Home | Imprint | This part of the site doesn't use cookies.