1--TEST-- 2ReflectionProperty::__construct(): ensure inherited private props can't be accessed through ReflectionProperty. 3--FILE-- 4<?php 5 6class C { 7 private $p = 1; 8 9 static function testFromC() { 10 try { 11 $rp = new ReflectionProperty("D", "p"); 12 var_dump($rp); 13 } catch (Exception $e) { 14 echo $e->getMessage(); 15 } 16 } 17} 18 19class D extends C{ 20 static function testFromD() { 21 try { 22 $rp = new ReflectionProperty("D", "p"); 23 var_dump($rp); 24 } catch (Exception $e) { 25 echo $e->getMessage(); 26 } 27 } 28} 29 30echo "--> Reflect inherited private from global scope:\n"; 31try { 32 $rp = new ReflectionProperty("D", "p"); 33 var_dump($rp); 34} catch (Exception $e) { 35 echo $e->getMessage(); 36} 37 38echo "\n\n--> Reflect inherited private from declaring scope:\n"; 39C::testFromC(); 40 41echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n"; 42D::testFromC(); 43 44echo "\n\n--> Reflect inherited private from subclass:\n"; 45D::testFromD(); 46?> 47--EXPECTF-- 48--> Reflect inherited private from global scope: 49Property D::$p does not exist 50 51--> Reflect inherited private from declaring scope: 52Property D::$p does not exist 53 54--> Reflect inherited private from declaring scope via subclass: 55Property D::$p does not exist 56 57--> Reflect inherited private from subclass: 58Property D::$p does not exist 59