Interface Default Methods improves backwards compatibility when changing interfaces, but also add a way to have multi-inheritance in PHP.
It looks pretty much the exact function as abstract class. I still think interfaces/contracts should not include any concrete implementation
Creating traits for default implementation is just a pain. I want syntactic sugar
Multi-inheritance seems to be the hot topic that prevented this RFC from being approved even though it was not the RFC target. Multi-inheritance is an afterthought that may or may not be abused with this change. What we want would actually be just the convenience of doing what Traits already allow while reducing potential BC break impact coming from interface changes. There are interfaces originated from the interface segregation mindset that often has only 1 implementation and could very well take advantage of default implementation for a simpler system design.
I'm not sure if allowing default implementations in interfaces is the way to go here.
To me it looks like a workaround / hack for non existing multi inheritance.
Why not either make multi inheritance possible instead or allow traits with interfaces as suggested by Victor?
Technically writing a trait isn't a showstopper, but it adds cognitive load because the developer now must know/remember using this Interface requires adding this Trait. PHP should focus more on development experience!
It will solve having to create traits to add a default implementation when creating interfaces and keeping it nicely together improving the DX
The only purpose of interface is to put restriction on architecture.
With interface we define how our code will be dealing with any "external" code - any code that does not know about implementation details. It can be system that uses our library, or just another module in our project decoupled from what is covered by an interface.
So interface is just a boundary, to keep things separated and protect it from unexpected changes.
We show only interfaces to "outer world" and that gives us freedom to make any changes to implementation details.
As long as we don't change interface itself, "outer" code must not change. So "outer" code is isolated and we benefit from that - the less changes we should make, the less error we do and less work overall.
It is the superpower and real purpose of existing of interfaces.
What if interface provide default implementation? It will change when we change the implementation details, so will change - and sometimes break - outer code. And isolation is no longer the case. Changing implementation details in our code we break outer code.
And interfaces with default implementation instantly loose its superpower.
From an architecture tool interface turns to dangerous and unpredictable creature.
So No. I don't want this RFC.
As with all other RFC with 'adding' behaviour, if you don't like it, just don't use it and left it for others :))
I personally don't need it but I guess it could be useful to people.
Sounds like a potential to mix up what's an interface and what's an abstract class
This sounds like C++ Multi-Inheritence with extrasteps. Please don't.
There are so many other, more elegant solutions to this problem that could solve it; multi-class-inheritance, traits-implementing-interfaces, etc. all to solve a problem I haven't really found myself running into more than once or twice in a number of years.
The "pipe operator" |>
allows you to chain multiple function calls in a more convenient way.
This RFC proposes a way to have multi-line short closures — closures that don't need explicit use
statements, but can still have multiple lines and a return statement.
A new syntax for declaring the “set” operation visibility of an object property