Bug #69238 [Opn]: getProperties() Doesn't list undeclared class properties
| From: | geolim4 at gmail dot com | Date: | Sat, 14 Mar 2015 23:46:44 +0000 |
| Subject: | Bug #69238 [Opn]: getProperties() Doesn't list undeclared class properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191389@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69238&edit=1
ID: 69238
User updated by: geolim4 at gmail dot com
Reported by: geolim4 at gmail dot com
Summary: getProperties() Doesn't list undeclared class
properties
Status: Open
Type: Bug
Package: Reflection related
Operating System: Debian 3.2.65-1+deb7u1 x86_64
PHP Version: 5.6.6
Block user comment: N
Private report: N
New Comment:
As you can see the test was done inside a namespace, the bug is also reproduced in global scope.
Previous Comments:
------------------------------------------------------------------------
[2015-03-14 23:44:59] geolim4 at gmail dot com
Description:
------------
It seem that ReflectionClass::getProperties() doesn't fetch undeclared properties of an object,
even if you specify all the filters such ReflectionProperty::IS_xxxxxx
Test script:
---------------
class foo
{
public $bar = false;
private $foobar = false;
function __construct()
{
$this->bar = false;
$this->foobar = true;
$this->baz = true;
}
}
$data = new foo();
$class = new \ReflectionClass($data);
$properties = $class->getProperties();
\var_dump( $properties );
exit;
Expected result:
----------------
array(2) {
[0]=>
&object(ReflectionProperty)#3 (2) {
["name"]=>
string(3) "bar"
["class"]=>
string(3) "foo"
}
[1]=>
&object(ReflectionProperty)#4 (2) {
["name"]=>
string(6) "foobar"
["class"]=>
string(3) "foo"
}
[2]=>
&object(ReflectionProperty)#4 (2) {
["name"]=>
string(6) "baz"
["class"]=>
string(3) "foo"
}
}
Actual result:
--------------
array(2) {
[0]=>
&object(ReflectionProperty)#3 (2) {
["name"]=>
string(3) "bar"
["class"]=>
string(3) "foo"
}
[1]=>
&object(ReflectionProperty)#4 (2) {
["name"]=>
string(6) "foobar"
["class"]=>
string(3) "foo"
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69238&edit=1