1--TEST-- 2ReflectionClass::getProperties() 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8class pubf { 9 public $a; 10 static public $s; 11} 12class subpubf extends pubf { 13} 14 15class protf { 16 protected $a; 17 static protected $s; 18} 19class subprotf extends protf { 20} 21 22class privf { 23 private $a; 24 static private $s; 25} 26class subprivf extends privf { 27} 28 29$classes = array("pubf", "subpubf", "protf", "subprotf", 30 "privf", "subprivf"); 31foreach($classes as $class) { 32 echo "Reflecting on class $class: \n"; 33 $rc = new ReflectionClass($class); 34 var_dump($rc->getProperties()); 35} 36 37?> 38--EXPECTF-- 39Reflecting on class pubf: 40array(2) { 41 [0]=> 42 &object(ReflectionProperty)#%d (2) { 43 [%u|b%"name"]=> 44 %unicode|string%(1) "a" 45 [%u|b%"class"]=> 46 %unicode|string%(4) "pubf" 47 } 48 [1]=> 49 &object(ReflectionProperty)#%d (2) { 50 [%u|b%"name"]=> 51 %unicode|string%(1) "s" 52 [%u|b%"class"]=> 53 %unicode|string%(4) "pubf" 54 } 55} 56Reflecting on class subpubf: 57array(2) { 58 [0]=> 59 &object(ReflectionProperty)#%d (2) { 60 [%u|b%"name"]=> 61 %unicode|string%(1) "a" 62 [%u|b%"class"]=> 63 %unicode|string%(4) "pubf" 64 } 65 [1]=> 66 &object(ReflectionProperty)#%d (2) { 67 [%u|b%"name"]=> 68 %unicode|string%(1) "s" 69 [%u|b%"class"]=> 70 %unicode|string%(4) "pubf" 71 } 72} 73Reflecting on class protf: 74array(2) { 75 [0]=> 76 &object(ReflectionProperty)#%d (2) { 77 [%u|b%"name"]=> 78 %unicode|string%(1) "a" 79 [%u|b%"class"]=> 80 %unicode|string%(5) "protf" 81 } 82 [1]=> 83 &object(ReflectionProperty)#%d (2) { 84 [%u|b%"name"]=> 85 %unicode|string%(1) "s" 86 [%u|b%"class"]=> 87 %unicode|string%(5) "protf" 88 } 89} 90Reflecting on class subprotf: 91array(2) { 92 [0]=> 93 &object(ReflectionProperty)#%d (2) { 94 [%u|b%"name"]=> 95 %unicode|string%(1) "a" 96 [%u|b%"class"]=> 97 %unicode|string%(5) "protf" 98 } 99 [1]=> 100 &object(ReflectionProperty)#%d (2) { 101 [%u|b%"name"]=> 102 %unicode|string%(1) "s" 103 [%u|b%"class"]=> 104 %unicode|string%(5) "protf" 105 } 106} 107Reflecting on class privf: 108array(2) { 109 [0]=> 110 &object(ReflectionProperty)#%d (2) { 111 [%u|b%"name"]=> 112 %unicode|string%(1) "a" 113 [%u|b%"class"]=> 114 %unicode|string%(5) "privf" 115 } 116 [1]=> 117 &object(ReflectionProperty)#%d (2) { 118 [%u|b%"name"]=> 119 %unicode|string%(1) "s" 120 [%u|b%"class"]=> 121 %unicode|string%(5) "privf" 122 } 123} 124Reflecting on class subprivf: 125array(0) { 126} 127