#39048 [Opn->Bgs]: Static variables and instantiated classes. private static doesn't work.

From: Date: Thu, 05 Oct 2006 14:32:48 +0000
Subject: #39048 [Opn->Bgs]: Static variables and instantiated classes. private static doesn't work.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103143@lists.php.net to get a copy of this message
ID: 39048 Updated by: tony2001@php.net Reported By: matti at nitro dot fi -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.1.6 New Comment: "self" (as well as "parent") is resolved in compile time, so it'll always point to the class where it was used. This is expected behaviour. Previous Comments: ------------------------------------------------------------------------ [2006-10-05 14:21:35] matti at nitro dot fi Description: ------------ self:: doesn't care for inheritance in instantiated classes. self:: doesn't care for private. private & static keywords don't work together. redeclaration of static variables doesn't work even for private static. Reproduce code: --------------- <?php class A { static $a = 1; function show() { echo self::$a; } } class B extends A { static $a = 2; } B::show(); // writes "1" not "2" $b = new B(); $b->show(); // writes "1" not "2" print '<hr />'; class C { private static $a = 1; function show() { echo self::$a; } } class D extends C { private static $a = 2; } D::show(); // writes "1" not "2" $d = new D(); $d->show(); // writes "1" not "2" ?> Expected result: ---------------- 22<hr />22 Actual result: -------------- 11<hr />11 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39048&edit=1

« previous php.bugs (#103143) next »