1--TEST-- 2ReflectionClass::[gs]etStaticPropertyValue 3--FILE-- 4<?php 5 6/* ReflectionClass cannot touch protected or private static properties */ 7 8/* ReflectionClass cannot create or delete static properties */ 9 10Class Test 11{ 12 static public $pub = 'pub'; 13 static protected $pro = 'pro'; 14 static private $pri = 'pri'; 15 16 static function testing() 17 { 18 $ref = new ReflectionClass('Test'); 19 20 foreach(array('pub', 'pro', 'pri') as $name) 21 { 22 try 23 { 24 var_dump($ref->getStaticPropertyValue($name)); 25 var_dump($ref->getStaticPropertyValue($name)); 26 $ref->setStaticPropertyValue($name, 'updated'); 27 var_dump($ref->getStaticPropertyValue($name)); 28 } 29 catch(Exception $e) 30 { 31 echo "EXCEPTION\n"; 32 } 33 } 34 } 35} 36 37Class TestDerived extends Test 38{ 39// static public $pub = 'pub'; 40// static protected $pro = 'pro'; 41 static private $pri = 'pri'; 42 43 static function testing() 44 { 45 $ref = new ReflectionClass('Test'); 46 47 foreach(array('pub', 'pro', 'pri') as $name) 48 { 49 try 50 { 51 var_dump($ref->getStaticPropertyValue($name)); 52 var_dump($ref->getStaticPropertyValue($name)); 53 $ref->setStaticPropertyValue($name, 'updated'); 54 var_dump($ref->getStaticPropertyValue($name)); 55 } 56 catch(Exception $e) 57 { 58 echo "EXCEPTION\n"; 59 } 60 } 61 } 62} 63 64$ref = new ReflectionClass('Test'); 65 66foreach(array('pub', 'pro', 'pri') as $name) 67{ 68 try 69 { 70 var_dump($ref->getStaticPropertyValue($name)); 71 var_dump($ref->getStaticPropertyValue($name)); 72 $ref->setStaticPropertyValue($name, 'updated'); 73 var_dump($ref->getStaticPropertyValue($name)); 74 } 75 catch(Exception $e) 76 { 77 echo "EXCEPTION\n"; 78 } 79} 80 81Test::testing(); 82TestDerived::testing(); 83 84?> 85--EXPECT-- 86string(3) "pub" 87string(3) "pub" 88string(7) "updated" 89string(3) "pro" 90string(3) "pro" 91string(7) "updated" 92string(3) "pri" 93string(3) "pri" 94string(7) "updated" 95string(7) "updated" 96string(7) "updated" 97string(7) "updated" 98string(7) "updated" 99string(7) "updated" 100string(7) "updated" 101string(7) "updated" 102string(7) "updated" 103string(7) "updated" 104string(7) "updated" 105string(7) "updated" 106string(7) "updated" 107string(7) "updated" 108string(7) "updated" 109string(7) "updated" 110string(7) "updated" 111string(7) "updated" 112string(7) "updated" 113