#26930 [Com]: Inheritance of static functions
| From: | kell_pt at users dot sf dot net | Date: | Fri, 21 May 2004 03:23:46 +0000 |
| Subject: | #26930 [Com]: Inheritance of static functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59825@lists.php.net to get a copy of this message | ||
ID: 26930
Comment by: kell_pt at users dot sf dot 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:
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. :)
Previous Comments:
------------------------------------------------------------------------
[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