Bug #62690 [Opn->Csd]: Sibling property with same name accessible in sibling is detected as accessible
| From: | requinix@php.net | Date: | Tue, 24 Oct 2017 08:23:03 +0000 |
| Subject: | Bug #62690 [Opn->Csd]: Sibling property with same name accessible in sibling is detected as accessible | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212253@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62690&edit=1
ID: 62690
Updated by: requinix@php.net
Reported by: cataphract@php.net
Summary: Sibling property with same name accessible in
sibling is detected as accessible
-Status: Open
+Status: Closed
Type: Bug
Package: Reflection related
Operating System: Irrelevant
PHP Version: master-Git-2012-07-29 (Git)
-Assigned To:
+Assigned To: requinix
Block user comment: N
Private report: N
New Comment:
Fixed since 7.1. https://3v4l.org/Y9ShB
Previous Comments:
------------------------------------------------------------------------
[2012-07-29 17:28:22] cataphract@php.net
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 this bug report at https://bugs.php.net/bug.php?id=62690&edit=1