withFoo2 example


    public function setFoo(FooAnnotation $foo)
    {
    }

    /** * @required */
    public function withFoo1(FooAnnotation $foo)static
    {
        return $this->withFoo2($foo);
    }

    /** * @required */
    public function withFoo2(FooAnnotation $foo)static
    {
        $new = clone $this;
        $new->foo = $foo;

        return $new;
    }

    protected static function getWitherService($container)
    {
        $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\WitherAnnotation();

        $a = new \Symfony\Component\DependencyInjection\Tests\Compiler\FooAnnotation();
        $a = $a->cloneFoo();

        $instance = $instance->withFoo1($a);
        $container->services['wither'] = $instance = $instance->withFoo2($a);
        $instance->setFoo($a);

        return $instance;
    }
}

    protected static function getWitherService($container)
    {
        $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither();

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

        $instance = $instance->withFoo1($a);
        $container->services['wither'] = $instance = $instance->withFoo2($a);
        $instance->setFoo($a);

        return $instance;
    }
}
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;
    }
}

class WitherProxy580fe0f extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface
{
    use \Symfony\Component\VarExporter\LazyProxyTrait;

    private const LAZY_OBJECT_PROPERTY_SCOPES = [
        
$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;
    }
}

class WitherProxyDd381be extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface
{
    use \Symfony\Component\VarExporter\LazyProxyTrait;

    private const LAZY_OBJECT_PROPERTY_SCOPES = [
        
Home | Imprint | This part of the site doesn't use cookies.