PHP5: Problem concerning multiple inheritance / interfaces

From: Date: Wed, 04 Feb 2004 16:19:40 +0000
Subject: PHP5: Problem concerning multiple inheritance / interfaces
Groups: php.qa 
Request: Send a blank email to php-qa+get-15919@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

« previous php.qa (#15919) next »