ID: 37682
Updated by: [EMAIL PROTECTED]
Reported By: ncosta at alum dot rpi dot edu
-Status: Open
+Status: Assigned
Bug Type: Scripting Engine problem
Operating System: Irrelevant
PHP Version: 5.1.4
-Assigned To:
+Assigned To: johannes
New Comment:
Already on my personal todo :-)
Previous Comments:
------------------------------------------------------------------------
[2006-06-02 17:31:01] ncosta at alum dot rpi dot edu
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 this bug report at http://bugs.php.net/?id=37682&edit=1