Why not introduce multiple inheritance directly to PHP instead of introducing traits?
Reply content:
Why not introduce multiple inheritance directly to PHP instead of introducing traits?
There's a lot of discussion online,
Wiki about 多重继承 the introduction: Https://zh.wikipedia.org/wiki/%E5%A4%9A%E9%87%8D%E7%BB%A7%E6%89%BF
If ClassA and ClassB in common eat() , then which one do you inherit?
Multiple inheritance, in many cases, is useful as a developer, but it greatly increases the complexity of both compiler developers and programmers. A problem occurs when the two parent class has a data member or a method with the same name. It is difficult to resolve the references that are being referenced by subclasses. In addition, when two parent classes inherit from the same base class, they are formed 钻石问题 .
Multiple inheritance has a large impact on design patterns. It
Multiple inheritance is a violation of many design patterns, and most languages are not used.
Although trait there are many similarities with many inheritance, but it is very good to avoid the problem of multiple inheritance, but also allow other language design ideas can be easily applied to the php .