Interface Default Methods improves backwards compatibility when changing interfaces, but also add a way to have multi-inheritance in PHP.
Multiple inheritance is probably a better solution. It's something that already exists in other languages and which we can certainly reimplement using their same solutions to the same problems (e.g. conflicting methods and properties). The functionality would then be more powerful and complete than this RFC.
..a controversial one indeed. Personally I would try to avoid this feature in my own code (just like I avoid traits and abstract classes because I feel that they are a sign of bad abstractions).
To me the fact that convinced me is the last section of the RFC:
This feature may be used to enhance existing interfaces in PHP. Countable could add function isEmpty(): bool { return $this->count() == 0; }. Iterator could add methods like map, filter, and reduce which behave similarly to array_map, array_filter, and array_reduce.
Implementing an interface is different than extending an abstract class
Interface MUST be just declaration and NO implementation at all
Its an interface is a contract. It should have no behavior.
Interfaces should not have specific implementations, but define specifications.
It feels like an anti-pattern, we still have traits to fix this kind of thing. Multi-inheritance is not possible unfortunately, but an interface should not be misused for this.
Having traits does not mean default methods in interfaces should no longer be allowed.
Interface = declaration Class = functionality
Interfaces should remain as defining the structure and the contract.
Keep interfaces to be interfaces!
This RFC could be useful if in PHP there was no inheritance and traits. But PHP has both traits and inheritance so this should be used.
Whether it's:
Separation of what and how. Besides this, it could pave the way for https://en.wikipedia.org/wiki/Multiple_inheritance which is also undesirable
I personally don't need it right now but I guess it could be useful to people, since other languages have it
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.
The "pipe operator" |>
allows you to chain multiple function calls in a more convenient way.
Chain method on newly created objects without parentheses