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

 ID:                 64592
 Patch added by:     larue...@php.net
 Reported by:        benjamin dot morel at gmail dot com
 Summary:            ReflectionClass::getMethods() returns methods out of
                     scope
 Status:             Open
 Type:               Bug
 Package:            Reflection related
 Operating System:   Linux
 PHP Version:        5.4.13
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: bug64592.patch
Revision:   1365254381
URL:        
https://bugs.php.net/patch-display.php?bug=64592&patch=bug64592.patch&revision=1365254381


Previous Comments:
------------------------------------------------------------------------
[2013-04-06 11:54:57] benjamin dot morel at gmail dot com

But at least, getMethods() and getProperties() should behave in the same way, 
shouldn't they?

------------------------------------------------------------------------
[2013-04-06 02:08:02] larue...@php.net

for php, even the private inherited function is not "visible", but it exists in 
the child function table.

------------------------------------------------------------------------
[2013-04-05 16:14:30] benjamin dot morel at gmail dot com

Description:
------------
As far as I understand it, ReflectionClass::getMethods() should return only the 
methods that are in the scope of the reflected class, thus excluding private 
methods from parent classes.

That's moreover the behaviour exposed by ReflectionClass::getProperties(), 
making 
the two methods behave in different manners.

Test script:
---------------
class Foo {
    private $a;
    private function a() {}

    protected $b;
    protected function b() {}
}
class Bar extends Foo {
    private $c;
    private function c() {}
}

$r = new ReflectionClass('Bar');

echo 'Properties in scope: ';
foreach ($r->getProperties() as $property) {
    echo $property->getName() . ' ';
}

echo PHP_EOL, 'Methods in scope: ';
foreach ($r->getMethods() as $method) {
    echo $method->getName() . ' ';
}

Expected result:
----------------
Properties in scope: c b 
Methods in scope: c b 

Actual result:
--------------
Properties in scope: c b 
Methods in scope: c a b 


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



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

Reply via email to