On Thu, Jun 15, 2023, 06:48 Levi Morrison via internals < internals@lists.php.net> wrote:
> Hello, PHP Internals, > > I am moving my RFC for interface default methods to discussion: > https://wiki.php.net/rfc/interface-default-methods. > > Thank you for your time. I look forward to productive feedback. > > Hi Levi, Thank you for this! I like the proposal and I think it fits well. I'm used to it from Java and I don't know any reason for it to be considered a bad practice since it was introduce, about 9-10 years ago. 1. Do we want to allow also private methods in the interface so that it allows code reuse or better code organization in smaller methods? Java introduced this only in the next version. The private methods would be invisible to implementing classes and to anything else, of course. We can also add them at a later point but it might be better to have the feature complete now. Sidenote: I don't think protected method should ever exist on interfaces; that should remain for abstract classes use case. 2. The only use case for myself for ever using traits would be if traits would offer a default implementation for an interface. Now with a default implementation offered by interface itself, sounds even better. However, I can see how there could be more than one provided default implementation that can be offered. Would a method implemented by a trait have higher precedence over the interface default implementation? Would a trait offered implementation be directly usable by the interface? Thanks, Alex