From:             
Operating system: Any
PHP version:      5.3.2
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:__get() and __set() for static classes

Description:
------------
Would it be possible to have magic setter/getter functions available on
static 

context ?



The documentation says "Property overloading only works in object context.
These 

magic methods will not be triggered in static context."



I would find it useful on a static context where I have a class A extending


another class B, to access





Test script:
---------------
Example:



Class A {



   static $data = array('bar' => 99, 'foo' => 101);

   

   function __get($name) {



       if (isset(self::$data[$name])) 

           return self::$data[$name];



       return null;

   }

}



Class B extends A {

   

}





echo B::$foo;

Expected result:
----------------
echo B::$foo; 



In the example should return 101.

Actual result:
--------------
In the example it triggers a fatal error.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52225&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52225&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52225&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52225&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52225&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52225&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52225&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52225&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52225&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52225&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52225&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52225&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52225&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52225&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52225&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52225&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52225&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52225&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52225&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52225&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52225&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52225&r=mysqlcfg

Reply via email to