New "static" keyword doesn't have private access?
| From: | Michael J. I. Jackson | Date: | Fri, 14 Dec 2007 23:07:39 +0000 |
| Subject: | New "static" keyword doesn't have private access? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-34038@lists.php.net to get a copy of this message | ||
Hello all,
I'm playing around with 5.3, and I noticed the following interesting behavior:
class A
{
private static $cls = __CLASS__;
public static function who()
{
print static::$cls;
}
}
class B extends A
{
private static $cls = __CLASS__;
}
B::who(); // Fatal error: Cannot access private property B::$cls
I understand why this is happening, but IMO, this should not be
throwing an error. If "static" is supposed to be referencing the
"called class", we need a way to access ALL of the variables of that
class from its parent classes. Otherwise, there is no way to create
static class variables that won't be inherited in a hierarchy. If
there is, and I'm missing it, please forgive me and point it out.
Regards,
Michael