xref: /PHP-7.3/ext/reflection/tests/bug49719.phpt (revision 782352c5)
1--TEST--
2Bug #49719 (ReflectionClass::hasProperty returns true for a private property in base class)
3--FILE--
4<?php
5
6class A {
7	private $a;
8}
9class B extends A {
10	private $b;
11}
12
13try {
14	$b = new B;
15	$ref = new ReflectionClass($b);
16
17	var_dump(property_exists('b', 'a'));
18	var_dump(property_exists($b, 'a'));
19	var_dump($ref->hasProperty('a'));
20	var_dump($ref->getProperty('a'));
21} catch (Exception $e) {
22	var_dump($e->getMessage());
23}
24
25class A2 {
26	private $a = 1;
27}
28
29class B2 extends A2 {
30	private $a = 2;
31}
32
33$b2 = new ReflectionClass('B2');
34$prop = $b2->getProperty('a');
35$prop->setAccessible(true);
36var_dump($prop->getValue(new b2));
37
38?>
39--EXPECTF--
40bool(false)
41bool(false)
42bool(false)
43string(25) "Property a does not exist"
44int(2)
45