From: cataphract
Operating system: Irrelevant
PHP version: master-Git-2012-07-29 (Git)
Package: Reflection related
Bug Type: Bug
Bug description:Sibling property with same name accessible in sibling is
detected as accessible
Description:
------------
See script.
Test script:
---------------
<?php
class Foo {}
class Bar extends Foo {
public $var = 'BarVar';
}
class Qux extends Foo {
private $var = 'QuxVar';
}
$class = new ReflectionClass('Bar');
$prop = $class->getProperty('var');
echo $prop->getValue(new Qux());
Expected result:
----------------
A 'ReflectionException' with message 'Given object is not an instance of
the class this property was declared in'.
This would mirror the behavior with methods:
<?php
class Foo {}
class Bar extends Foo {
function foo() {}
}
class Qux extends Foo {
private function foo() {}
}
$class = new ReflectionClass('Bar');
$meth = $class->getMethod('foo');
$meth->invoke(new Qux());
PHP Fatal error: Uncaught exception 'ReflectionException' with message
'Given object is not an instance of the class this method was declared in'
Actual result:
--------------
PHP Fatal error: Cannot access private property Qux::$var
--
Edit bug report at https://bugs.php.net/bug.php?id=62690&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62690&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62690&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62690&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62690&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62690&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62690&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62690&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62690&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62690&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62690&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62690&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62690&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62690&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62690&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62690&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62690&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62690&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62690&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62690&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62690&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62690&r=mysqlcfg