|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-22 13:11 UTC] 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 16:00:01 2025 UTC |
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.