Bug #63582 [Opn->Nab]: ReflectionClass->getProperties() omits private members of parent classes

From: Date: Fri, 23 Nov 2012 01:54:10 +0000
Subject: Bug #63582 [Opn->Nab]: ReflectionClass->getProperties() omits private members of parent classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174861@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63582&edit=1

 ID:                 63582
 Updated by:         aharvey@php.net
 Reported by:        anthon dot pang at gmail dot com
 Summary:            ReflectionClass->getProperties() omits private
                     members of parent classes
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Reflection related
 Operating System:   Ubuntu 12.04
 PHP Version:        5.5.0alpha1
 Block user comment: N
 Private report:     N

 New Comment:

Private properties and methods only exist within the exact class they are defined in: note that if
you call getParentClass() on the $reflection object and then call getProperties() on that,
"c" appears along with the other properties defined in Foo.


Previous Comments:
------------------------------------------------------------------------
[2012-11-22 16:12:23] anthon dot pang at gmail dot com

Description:
------------
getProperties() doesn't include "private" scoped properties from parent classes

Test script:
---------------
<?php
abstract class Foo {
    public  $a;
    protected $b;
    private $c;
}

class Bar extends Foo {
    public $d;
    protected $e;
    private $f;
}

$obj = new Bar;
$reflection = new ReflectionClass($obj);
$propertyList = $reflection->getProperties();

foreach ($propertyList as $property) {
    var_dump($property->getName());
}

Expected result:
----------------
string(1) "d"
string(1) "e"
string(1) "f"
string(1) "a"
string(1) "b"
string(1) "c"

Actual result:
--------------
string(1) "d"
string(1) "e"
string(1) "f"
string(1) "a"
string(1) "b"


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63582&edit=1


Thread (3 messages)

« previous php.bugs (#174861) next »