On Wed, Jul 24, 2024, at 16:28, Nicolas Grekas wrote:
> 
> To Rob: proxying by interface can be implemented using regular code 
> generation so it's not a blocker. Symfony does it already, and will continue 
> to do it to cover the use case.

I'm not sure what you mean, as the RFC makes it look this should be completely 
legal, until you get to the end:

interface Fancy {
  function sayHi(): void;
}
class A implements Fancy {
  function sayHi(): void { echo "hi!"; }
}

$container->register(proxyType: Fancy::class, factory: fn() => new A());

// Now container only knows that it needs to return a FancyClass and this is 
"legal looking":

$lazy = new ReflectionClass($proxyType)->newLazyProxy($factory);
// same as
$lazy = new ReflectionClass(Fancy::class)->newLazyProxy(fn() => new A());

This ^ compiles, it's perfectly legal and makes 100% sense that I should be 
able to call $lazy->sayHi() and it calls A::sayHi(), which is what you would 
expect. Instead, this is runtime error.

— Rob

Reply via email to