From: joh at deworks dot net Operating system: Linux PHP version: 5CVS-2005-02-23 (dev) PHP Bug Type: Feature/Change Request Bug description: Overloading for static methods and properties
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 bug report at http://bugs.php.net/?id=32073&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32073&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32073&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32073&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32073&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32073&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32073&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32073&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32073&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32073&r=support Expected behavior: http://bugs.php.net/fix.php?id=32073&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32073&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32073&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32073&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32073&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32073&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32073&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32073&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32073&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32073&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32073&r=mysqlcfg