From: Operating system: linux PHP version: 5.3.6 Package: Reflection related Bug Type: Bug Bug description:ReflectionClass::setStaticPropertyValue does not work for protected/private
Description: ------------ --- >From manual page: http://www.php.net/reflectionclass.setstaticpropertyvalue#Description --- ReflectionClass::getProperties() shows public, protected and private members, but ReflectionClass::setStaticPropertyValue throws a fatal error if a protected or private member is set. The error message says that "Class Tehst does not have a property named prot", which is plain wrong. Test script: --------------- <?php class Tehst { public static $pub = 'pub'; protected static $prot = 'prot'; private static $priv = 'priv'; } $rT = new ReflectionClass( 'Tehst' ); var_export( $rT->getProperties() ); $rT->setStaticPropertyValue( 'pub', 'myPub' ); $rT->setStaticPropertyValue( 'prot', 'myProt' ); $rT->setStaticPropertyValue( 'priv', 'myPriv' ); ?> Expected result: ---------------- array ( 0 => ReflectionProperty::__set_state(array( 'name' => 'pub', 'class' => 'Tehst', )), 1 => ReflectionProperty::__set_state(array( 'name' => 'prot', 'class' => 'Tehst', )), 2 => ReflectionProperty::__set_state(array( 'name' => 'priv', 'class' => 'Tehst', )), )pub: myPub Actual result: -------------- array ( 0 => ReflectionProperty::__set_state(array( 'name' => 'pub', 'class' => 'Tehst', )), 1 => ReflectionProperty::__set_state(array( 'name' => 'prot', 'class' => 'Tehst', )), 2 => ReflectionProperty::__set_state(array( 'name' => 'priv', 'class' => 'Tehst', )), )pub: myPub PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class Tehst does not have a property named prot' in /home/jay/public_html/alis/newfile.php:14 Stack trace: #0 /home/jay/public_html/alis/newfile.php(14): ReflectionClass->setStaticPropertyValue('prot', 'myProt') #1 {main} thrown in /home/jay/public_html/alis/newfile.php on line 14 Fatal error: Uncaught exception 'ReflectionException' with message 'Class Tehst does not have a property named prot' in /home/jay/public_html/alis/newfile.php:14 Stack trace: #0 /home/jay/public_html/alis/newfile.php(14): ReflectionClass->setStaticPropertyValue('prot', 'myProt') #1 {main} thrown in /home/jay/public_html/alis/newfile.php on line 14 -- Edit bug report at http://bugs.php.net/bug.php?id=54620&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54620&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54620&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54620&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54620&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54620&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54620&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54620&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54620&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54620&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54620&r=support Expected behavior: http://bugs.php.net/fix.php?id=54620&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54620&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54620&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54620&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54620&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54620&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54620&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54620&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54620&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54620&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54620&r=mysqlcfg