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

 ID:                 63582
 User updated by:    anthon dot pang at gmail dot com
 Reported by:        anthon dot pang at gmail dot com
 Summary:            ReflectionClass->getProperties() omits private
                     members of parent classes
 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:

Thanks for the explanation.


Previous Comments:
------------------------------------------------------------------------
[2012-11-23 01:54:10] ahar...@php.net

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.

------------------------------------------------------------------------
[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

Reply via email to