|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-06-02 19:30 UTC] johannes@php.net
[2006-08-25 17:23 UTC] bjori@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 15 10:00:01 2025 UTC |
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 ) )