[Pre RFC] Automated delegation using implements by

From: Date: Thu, 01 Oct 2026 00:29:56 +0000
Subject: [Pre RFC] Automated delegation using implements by
Groups: php.internals 
Request: Send a blank email to internals+get-132737@lists.php.net to get a copy of this message
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.

« previous php.internals (#132737) next »