withFoo example

public function testWith()
    {
        $contextBuilder = new class() {
            use ContextBuilderTrait;

            public function withFoo(string $value)static
            {
                return $this->with('foo', $value);
            }
        };

        $context = $contextBuilder->withFoo('bar')->toArray();

        $this->assertSame(['foo' => 'bar']$context);
    }
}
/** * Gets the public 'wither' shared autowired service. * * @return \Symfony\Component\DependencyInjection\Tests\Fixtures\WitherStaticReturnType */
    protected static function getWitherService($container)
    {
        $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\WitherStaticReturnType();

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

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

        return $instance;
    }
}
public function withFoo($foo)static
            {
                $clone = clone $this;
                $clone->foo = $foo;

                return $clone;
            }
        };
        $proxy = $this->createLazyProxy($obj::classfn () => $obj);

        $clone = $proxy->withFoo(234);
        $this->assertSame($clone::class$proxy::class);
        $this->assertSame(234, $clone->foo);
        $this->assertSame(234, $obj->foo);
    }

    public function testFluent()
    {
        $obj = new class() {
            public $foo = 123;

            public function setFoo($foo)static
            {
Home | Imprint | This part of the site doesn't use cookies.