#37682 [Asn->Csd]: ReflectionObject::getProperties() does not return dynamic properties
| From: | bjori@php.net | Date: | Fri, 25 Aug 2006 17:23:46 +0000 |
| Subject: | #37682 [Asn->Csd]: ReflectionObject::getProperties() does not return dynamic properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101336@lists.php.net to get a copy of this message | ||
ID: 37682
Updated by: bjori@php.net
Reported By: ncosta at alum dot rpi dot edu
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: Irrelevant
PHP Version: 5.1.4
Assigned To: johannes
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Marcus fixed this couple of months ago in HEAD and 5_2
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.7&r2=1.164.2.33.2.8&pathrev=PHP_5_2
Previous Comments:
------------------------------------------------------------------------
[2006-06-02 19:30:25] johannes@php.net
Already on my personal todo :-)
------------------------------------------------------------------------
[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