> Not exactly, How you wanna solve by abstract class two interfaces > which can be implemented using let's say two traits - let's say > > interface Foo { > public function foo(): string; > } > trait HasFoo { > public function foo(): string { return 'foo'; } > } > interface Bar { > public function bar(): bool; > } > traitHasBar { > public function bar(): bool { return true; } > } > > Now I can need to implement Foo or Bar separately or together. > Using abstract class that would require 3 abstract classes: Foo, Bar, and > FooWithBar. > With this RFC that would require just two interfaces with default methods.
This seems like a software design issue, not a language issue... But 3 abstract classes vs. 2 interfaces + 2 traits seems like a better tradeoff if you're going to need the coupling anyway. It's more obvious that you want/require FooWithBar when you want it. If you're expecting these exact implementations, moving them to the interface makes it even more confusing. I want FooWithBar (iow, I want these exact implementations) I want Foo&Bar (iow, I don't care about the implementation) You can pass a FooWithBar to Foo&Bar, but you can't pass a Foo&Bar to a FooWithBar. If the default implementation is on the interface ... who knows what you have, you'll have to check you /vendor folder. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php