Hello,

I submitted a draft RFC to https://github.com/php/php-src/pull/24030. The
PR contains an implementation and tests (please be gentle, I haven't
written C in decades).

I propose an "implements by" syntax to automate delegation, closely
modelled on Kotlin.

In short,

interface T { function foo(); }
class A implements T { function foo() { print "A"; } }
class C implements T by $t { function __construct(private T $t) {} }
new C(new A)->foo();

The performance impact should be minimal as everything happens at compile
time and during class linking with no runtime changes. There is no BC
break. (That's the intention, at least. I modelled the change after enum.)

Regards

Karoly Negyesi

P.S. Credit to Larry Garfield for pushing for this better syntax than my
original idea.

Reply via email to