ID: 30934 Comment by: mongole at tuivelsminne dot at Reported By: jbs at fromru dot com Status: Feedback Bug Type: Class/Object related Operating System: Windows XP Pro SP1 PHP Version: 5.0.2 Assigned To: andi New Comment:
I reproduced the bug with snapshot php5-200503262330, compiled as mod_php in apache-1.3.33 on FC 3. Previous Comments: ------------------------------------------------------------------------ [2005-03-25 01:21:31] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-02-28 21:21:44] [EMAIL PROTECTED] What's the verdict? ------------------------------------------------------------------------ [2005-01-17 13:47:32] Jason at amp-design dot net What is also most annoying is this doesn't just affect constants, it affects anything that can be static, that is constants, class members, and methods. This looks like a rather design descision that PHP people did (I guess initially it seemed good from a speed POV). ------------------------------------------------------------------------ [2005-01-17 13:33:40] Jason at amp-design dot net I agree, this is damn annoying. However, I'm sure the PHP team will come back saying "Sorry this is not a bug, it's an undocumented feature". I think this because I remember reading somewhere the ZE2 deals with constants on compile time, and therefore any references to self inside a class will point to the the class name that the reference to self points to. Ideally, if a class is extended, methods should be checked to see if the parent references self, and this should then check if the item inside self is referenced in the current class, or the parent class and adapt accordingly. It would be so nice if this can be fixed, but I have a nasty felling people have to live with this :( ------------------------------------------------------------------------ [2004-11-29 22:02:49] jbs at fromru dot com Description: ------------ Special keyword 'self' represents the parent class instead of the child class when it is used in an inherited method of the parent class. Reproduce code: --------------- class Foo { const NAME = 'Foo'; static public function display() { echo self::NAME; } static public function getInstance() { $instance = new self; return $instance; } } class Child extends Foo { const NAME = 'Child'; } echo('Class constant: '); Child::display(); echo('<BR>Object class: '); echo(get_class(Child::getInstance())); Expected result: ---------------- Class constant: Child Object class: Child Actual result: -------------- Class constant: Foo Object class: Foo ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30934&edit=1