ID: 39048
Updated by: [EMAIL PROTECTED]
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