Re: [Pre RFC] Automated delegation using implements by

From: Date: Thu, 01 Oct 2026 03:55:14 +0000
Subject: Re: [Pre RFC] Automated delegation using implements by
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-132738@lists.php.net to get a copy of this message
On Sep 30, 2026, at 9:29 PM, Karoly Negyesi <chx1975@gmail.com> wrote: > > 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. > The RFC itself needs to be posted to wiki.php.net (and link to your implementation PR). See below link for the process there and how to get access to edit: https://wiki.php.net/rfc/howto

« previous php.internals (#132738) next »