Multiple Inheritance
Note: Multiple Inheritance functionality may or may not be a part of the Zend Engine
2.0. Whether it is added to the engine or not will be publicly discussed.
Background
In the Zend Engine 1.0, classes can only inherit the interface and functionality of a single
parent class.
Need
Sometimes, one may wish to create a class that uses functionality from several parent
classes. This could be done if inheriting from multiple classes were possible.
Overview
The Zend Engine 2.0 will allow classes to inherit from more than one parent class. The
resulting class will have the methods of all of its parent classes, in addition to the
methods defined in the class itself. As with single inheritance, the child class will be able
to override any method from its parent classes. In case two parent classes have methods
with identical names, the child class will be forced to override the method (if possible,
the Zend Engine will detect whether the two methods are actually the very same method
(in case of ‘diamond-shaped’ inheritance), and will automatically resolve the conflict.
Functionality
Implementing classes that inherit from multiple parent classes will use the following
notation:
class child extends parent1, parent2, … {
…
};
Compatibility notes
Certain functions, such as get_parent_class() will have to change (e.g., to return the list
of parent classes, or just one of the parent classes arbitrarily). Otherwise, multiple
inheritance is downwards compatible with single inheritance, so it should introduce no
compatibility issues. Dependencies of feature
In order to implement a sound class hierarchy based on multiple inheritance, it will be
necessary to use private member variables. In that sense, this functionality depends on
the private member variables feature