PHP5: Problem concerning multiple inheritance / interfaces
| From: | Vivian Steller | Date: | Thu, 05 Feb 2004 01:28:08 +0000 |
| Subject: | PHP5: Problem concerning multiple inheritance / interfaces | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176855@lists.php.net to get a copy of this message | ||
Hello at all,
ok my problem in a nutshell: i need multiple inheritance! is there a
solution to fake this functionallity in php5?
i have the following problem:
the goal is to implement my own DomXML implementation based on the existing
DomNode, DomDocument, Dom... Classes.
thus, i implement my classes as follows:
class MyNode extends DomNode {} // that isn't the problem
class MyDocument extends DomDocument {} // would be fine, but...
this would be an easy solution, but there is a logical problem:
if i extend the DomNode (with the methods in MyNode) then -i think-
MyDocument should have those extended methods, too.
so i could write:
class MyDocument extends MyNode {} // problem
but now i'm missing all the nice methods of DomDocument!!
multiple inheritance would solve this problem:
class MyDocument extends MyNode,DomDocument {} // not possible
by the way: i will get into trouble with all Dom-Classes:
class MyElement extends MyNode,DomElement {}
class MyAttribute ...
Hope you'll understand me?
Is there a way to solve this problem?
I'm thinking about the new __call() method implemented as follows:
class MyDocument extends MyNode {
function __call($method, $params) { // fake solution
...
eval("DomDocument::$method($paramsString);");
}
}
but with a fake solution like this i wouldn't get all methods with
get_class_methods() and that wouldn't be that nice:)
Can Interfaces help me?
Thanks for your efforts..
vivi