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 ["name"]=> 44 string(1) "a" 45 ["class"]=> 46 string(4) "pubf" 47 } 48 [1]=> 49 object(ReflectionProperty)#%d (2) { 50 ["name"]=> 51 string(1) "s" 52 ["class"]=> 53 string(4) "pubf" 54 } 55} 56Reflecting on class subpubf: 57array(2) { 58 [0]=> 59 object(ReflectionProperty)#%d (2) { 60 ["name"]=> 61 string(1) "a" 62 ["class"]=> 63 string(4) "pubf" 64 } 65 [1]=> 66 object(ReflectionProperty)#%d (2) { 67 ["name"]=> 68 string(1) "s" 69 ["class"]=> 70 string(4) "pubf" 71 } 72} 73Reflecting on class protf: 74array(2) { 75 [0]=> 76 object(ReflectionProperty)#%d (2) { 77 ["name"]=> 78 string(1) "a" 79 ["class"]=> 80 string(5) "protf" 81 } 82 [1]=> 83 object(ReflectionProperty)#%d (2) { 84 ["name"]=> 85 string(1) "s" 86 ["class"]=> 87 string(5) "protf" 88 } 89} 90Reflecting on class subprotf: 91array(2) { 92 [0]=> 93 object(ReflectionProperty)#%d (2) { 94 ["name"]=> 95 string(1) "a" 96 ["class"]=> 97 string(5) "protf" 98 } 99 [1]=> 100 object(ReflectionProperty)#%d (2) { 101 ["name"]=> 102 string(1) "s" 103 ["class"]=> 104 string(5) "protf" 105 } 106} 107Reflecting on class privf: 108array(2) { 109 [0]=> 110 object(ReflectionProperty)#%d (2) { 111 ["name"]=> 112 string(1) "a" 113 ["class"]=> 114 string(5) "privf" 115 } 116 [1]=> 117 object(ReflectionProperty)#%d (2) { 118 ["name"]=> 119 string(1) "s" 120 ["class"]=> 121 string(5) "privf" 122 } 123} 124Reflecting on class subprivf: 125array(0) { 126} 127