ID: 41162 User updated by: bugs dot php dot net dot nsp at cvogt dot org Reported By: bugs dot php dot net dot nsp at cvogt dot org Status: Closed Bug Type: Class/Object related Operating System: * PHP Version: * New Comment:
I see your point now, thx for your answer. pecl/runkit "For all those things you.... probably shouldn't have been doing anyway...." ;). Good to keep in mind that such thing exists, might come in handy some time. Thx for the hint. Previous Comments: ------------------------------------------------------------------------ [2007-05-01 22:18:52] [EMAIL PROTECTED] Sorry for the type, it should read "mixing". Once again. Interfaces are declared stuff - __call is not. Since PHP does not have templates and will never have them that is the end of the story. Well you could experiment with pecl/runkit' runkit_method_add(). ------------------------------------------------------------------------ [2007-05-01 21:30:19] bugs dot php dot net dot nsp at cvogt dot org Isn't __call a reasonable way to implement methods? Sorry to re-open this one, but I am not convinced of the opposite yet. But I am open for an explanation. ------------------------------------------------------------------------ [2007-04-22 15:06:59] bugs dot php dot net dot nsp at cvogt dot org Thank you for the quick reply and the proposed generic function body. What do you mean by "You would be missing two completely different things, descriptive and non descriptive semantic elements."? I could use function <name>(<signature>) { $args = func_get_args(); return $this->__call(__FUNCTION__, $args); } (which fixes 2 bugs in your suggestion) but I would prefer an abstraction over copy&paste. ------------------------------------------------------------------------ [2007-04-22 13:21:55] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You would be missing two completely different things, descriptive and non descriptive semantic elements. What you can do is providing the implementation of the interface methods all with the same body: function <name>(<signature>) { return $this->__call(array($this, __FUNCTION__), func_get_args()); } where <name> and <signature> have to be replaced with the method name in question and its parameters respectively. ------------------------------------------------------------------------ [2007-04-22 13:11:39] bugs dot php dot net dot nsp at cvogt dot org Description: ------------ When implementing an interface one cannot use __call to implement methods as this will lead to a FATAL ERROR. However it would be quite convenient if one could do this. It would e.g. allow to generically pass on method calls to an object that is stored in a local variable and implements the interface. Reproduce code: --------------- interface MyInterface{ public function myMethod(); } class MyImplementation implements MyInterface{ public function __call( $method, $parameters ){ // do something } } Expected result: ---------------- __call takes care of not explicitly implemented methods declared in MyInterface. Actual result: -------------- Fatal error: Class MyImplementation contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::myMethod) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41162&edit=1