Open utterances-bot opened 1 year ago
As you can see from the code, on calling the method greet() using object ClassC, it’s impossible for the compiler to decide whether it has to call ClassA’s greet() or ClassB’s greet() method. So, this is to avoid such complications, PHP does not support multiple inheritance.
From any problems with multiple inheritance you choose the one that can be fixed with like throwing exception?
I see your point, but I don't think thats proper argument. Other arguments and composition over inheritance I am all in 🙌
As you can see from the code, on calling the method greet() using object ClassC, it’s impossible for the compiler to decide whether it has to call ClassA’s greet() or ClassB’s greet() method. So, this is to avoid such complications, PHP does not support multiple inheritance.
Can you explain problems with multiple inheritance you choose the one that can be fixed with like throwing exception?
This is why PHP don't have multiple inheritance — Amit Merchant — A blog on PHP, JavaScript, and more
In this article, I will discuss about why PHP don’t support multiple inheritance and how it has resolved this issue by allowing classes to implement multiple interfaces.
https://www.amitmerchant.com/this-is-why-php-dont-have-multiple-inheritance/