|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-12 14:48 UTC] ghostwwinside at gmx dot net
[2014-05-08 18:00 UTC] levim@php.net
-Status: Open
+Status: Duplicate
-Package: Feature/Change Request
+Package: Scripting Engine problem
[2014-05-08 18:00 UTC] levim@php.net
[2014-05-08 18:01 UTC] levim@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
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 ...