#37682 [NEW]: ReflectionObject::getProperties() does not return dynamic properties

From: Date: Fri, 02 Jun 2006 17:31:01 +0000
Subject: #37682 [NEW]: ReflectionObject::getProperties() does not return dynamic properties
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97984@lists.php.net to get a copy of this message
From: ncosta at alum dot rpi dot edu Operating system: Irrelevant PHP version: 5.1.4 PHP Bug Type: Scripting Engine problem Bug description: ReflectionObject::getProperties() does not return dynamic properties Description: ------------ The method ReflectionObject::getProperties() fails to return any dynamically-set properties of an object. The Reflection API is aware of them, because they appear in an export (as shown below) and are found by ReflectionObject::hasProperty(), but they do not appear in the array returned by getProperties (). There is no "getDynamicProperties()" method, and so without specific documentation it stands to reason that getProperties() should return ALL of an object's visible properties, both compile-time and run-time. Reproduce code: --------------- class Foo { public $bar; } $p = new Foo; $p->baz = 4; $r = new ReflectionObject( $p ); Reflection::export( $r ); print_r( $r->getProperties() ); Expected result: ---------------- Object of class [ class Foo ] { @@ /var/www/test.php 3-6 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $bar ] } - Dynamic properties [1] { Property [ public $baz ] } - Methods [0] { } } Array ( [0] => ReflectionProperty Object ( [name] => bar [class] => Foo ) [1] => ReflectionProperty Object ( [name] => baz [class] => Foo ) ) Actual result: -------------- Object of class [ class Foo ] { @@ /var/www/test.php 3-6 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $bar ] } - Dynamic properties [1] { Property [ public $baz ] } - Methods [0] { } } Array ( [0] => ReflectionProperty Object ( [name] => bar [class] => Foo ) ) -- Edit bug report at http://bugs.php.net/?id=37682&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37682&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37682&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37682&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37682&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37682&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37682&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37682&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37682&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37682&r=support Expected behavior: http://bugs.php.net/fix.php?id=37682&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37682&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37682&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37682&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37682&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37682&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37682&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37682&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37682&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37682&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37682&r=mysqlcfg

« previous php.bugs (#97984) next »