ID: 32073 Comment by: ghostwwinside at gmx dot net Reported By: joh at deworks dot net Status: Open Bug Type: Feature/Change Request Operating System: Linux PHP Version: 5CVS-2005-02-23 (dev) New Comment:
I think the overloading documentation is a bit unclear, beacause it mention "Class members" and do not restrict it to "Instance members". Previous Comments: ------------------------------------------------------------------------ [2005-02-23 01:58:06] joh at deworks dot net Description: ------------ Currently, it is only possible to overload method calls and member accesses of an object. The use of static classes with static methods and members is a good way to organize different parts of an application. Therefore, it would've be convenient to be able to overload static method calls and member accesses as you can do on objects. As a static class member/method cannot have the same name as a normal class member/method, this should be possible. This would give the developer finer controll over his/her static libraries. In the provided example, the developer could restrict access to the static member Foo::$readonly. Reproduce code: --------------- <?php class Foo { protected static $readonly = "Read-only member"; public static function __get($name) { switch ($name) { case 'readonly': return self::$readonly; break; default: break; } } } echo Foo::$readonly; Foo::$readonly = "Not possible."; ?> Expected result: ---------------- Read-only member Actual result: -------------- Fatal error: Cannot access protected property Foo::$readonly ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32073&edit=1