ID: 26930 Updated by: [EMAIL PROTECTED] Reported By: reckert at informationsgesellschaft dot com Status: Bogus Bug Type: Documentation problem Operating System: * PHP Version: * Assigned To: helly New Comment:
Fixed in documentation (bla dot) Previous Comments: ------------------------------------------------------------------------ [2004-09-30 18:22:57] kell_pt at users dot sf dot net I also filed a bug regarding this problem. It's not so much a problem as how it works, but how it SHOULD work. It is counter-intuitive the way inheritance works on static methods, and should be addressed at least with a mention in the manual. ------------------------------------------------------------------------ [2004-05-21 10:17:05] [EMAIL PROTECTED] Dynamic binding has nothing to do with the caller of a method/function, it is based on the [runtime] class of the object instance whose method is being called. Static methods do no operate on object instances, so dynamic binding is impossible. No compiled OO language does this. For PHP, it would also break BC. ------------------------------------------------------------------------ [2004-05-21 05:23:42] kell_pt at users dot sf dot net I beg to differ. If you call b::callInit() and b:: has init() redefined, it SHOULD call the b::init when refering to self, regardless of where that "self" is included. Basically, "self" must take in consideration the caller. This is not the only hint that the class mechanism is flawed in what concerns to static methods / properties. Static data and methods should follow the same concepts from class instances - it's how OOP works - change that and you can't really claim it's OOP. :) ------------------------------------------------------------------------ [2004-01-16 05:08:56] [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 inside callInit self === a ------------------------------------------------------------------------ [2004-01-16 04:58:48] reckert at informationsgesellschaft dot com Description: ------------ In a static function X a call to another static function in the same class uses the version of the function in the class where X is implemented, not the one for which X was called for. Reproduce code: --------------- class a { static function init() { echo 'a::init()'; } static function callInit() { self::init(); // do something important } } class b extends a { static function init() { echo 'b::init()'; } } b::callInit(); Expected result: ---------------- b::init() Actual result: -------------- a::init() Shouldn't inheritance work the same way as for normal methods? Thanks for comments, Ralph ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26930&edit=1