__call() and interfaces

From: Date: Wed, 22 Feb 2006 00:41:46 +0000
Subject: __call() and interfaces
Groups: php.general 
Request: Send a blank email to php-general+get-230862@lists.php.net to get a copy of this message
Hello World :) I need to write a class that implements a predefined interface. In my class all(or most) methods will use the same code. At first i thought the ideal solution would be to handle this by defining the magic __call() method in my class, but PHP then complains about the interface not being completely implemented. (Is there no way to tell PHP that the methods are handled by __call()?) Options i see right now: a) Just omit "implements SomeInterface" and PHP will stop complaining. This would be suboptimal as i want my class to "officially" conform to the standardized API which is defined in the interface. b) Implement all methods and just copy-paste the code. I find this rather ugly and it's a hassle to maintain. Is there a better solution than copy-paste(Keep in mind that the methods vary in argument types, argument counts and return value types)? Somehow neither a) nor b) seems "the right way" to do what i want, so i would be glad to hear your opinions on this. I would also be interested what the best solution would be from a performance point of view. Regards, Mike

« previous php.general (#230862) next »