From: denis at edistar dot com
Operating system: Linux
PHP version: 5.2.0
PHP Bug Type: Scripting Engine problem
Bug description: __set and __get not called where a class attribute is called
statically
Description:
------------
Static class attributes cannot be accessed using __get and
__set methods.
I think probably because they are resolved at compile time
and not at runtime. If not, it is a bug.
According to the documentation it should be possibile to
access static class attributes using __get and __get.
Reproduce code:
---------------
class myClass {
public function __set($name,$value) {
echo "Setting: " . $name . " to " . $value."\n";
self::$$name = $value;
}
public function __get($name) {
echo "Getting: " . $name . "\n";
}
}
myClass::$myStaticVar = "test";
echo myClass::$myStaticVar;
Expected result:
----------------
Setting: myStaticVar to test
Getting: myStaticVar
test
Actual result:
--------------
Fatal error: Access to undeclared static property:
myClass::$myStaticVar
--
Edit bug report at http://bugs.php.net/?id=39678&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39678&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39678&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39678&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39678&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39678&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39678&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39678&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39678&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39678&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39678&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39678&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39678&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39678&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39678&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39678&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39678&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39678&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39678&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39678&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39678&r=mysqlcfg