#26930 [Bgs]: Inheritance of static functions
| From: | abies@php.net | Date: | Fri, 21 May 2004 08:17:07 +0000 |
| Subject: | #26930 [Bgs]: Inheritance of static functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59830@lists.php.net to get a copy of this message | ||
ID: 26930
Updated by: abies@php.net
Reported By: reckert at informationsgesellschaft dot com
Status: Bogus
Bug Type: Zend Engine 2 problem
Operating System: Windows XP
PHP Version: 5CVS-2004-01-16 (dev)
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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] helly@php.net
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