Hi Levi > I am moving my RFC for interface default methods to discussion: > https://wiki.php.net/rfc/interface-default-methods.
This or a similar concept makes sense to me. The proposal seems similar to Swift protocol extensions, or Rust traits, with the exception that function default implementations may only be defined in the interface itself. Note that there's a large overlap between this proposal and extending traits to allow implementing interfaces. https://wiki.php.net/rfc/traits-with-interfaces The main difference is how you would use the feature from a given class, i.e. using an interface implementation or a trait usage. Implementing interfaces from traits would require declaring both a trait and an interface. I do think your proposal is the more natural approach. The redundancy of interfaces and traits after this RFC are also somewhat unfortunate. Both interfaces and traits could inject default behavior into classes. Both could enforce implementation of methods in classes (traits through abstract methods). My intuition is that interface default implementations should be used for public APIs (because this provides an abstracted interface), while traits should be used for protected/private ones (because non-public methods can't be added to interfaces). The other obvious difference is that interfaces don't allow manual conflict resolution while traits do. The RFC doesn't mention default implementations for static methods. I'm not sure there's a use case but it might make sense to explicitly mention whether they are supported. Ilija -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php