#39678 [Opn->Bgs]: __set and __get not called where a class attribute is called statically

From: Date: Wed, 29 Nov 2006 10:21:04 +0000
Subject: #39678 [Opn->Bgs]: __set and __get not called where a class attribute is called statically
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105616@lists.php.net to get a copy of this message
ID: 39678 Updated by: tony2001@php.net Reported By: denis at edistar dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 5.2.0 New Comment: This is expected behaviour. Previous Comments: ------------------------------------------------------------------------ [2006-11-29 10:03:05] denis at edistar dot com 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 this bug report at http://bugs.php.net/?id=39678&edit=1

« previous php.bugs (#105616) next »