Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_getProperty_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionClass::getProperty()
3: --CREDITS--
4: Robin Fernandes <robinf@php.net>
5: Steve Seear <stevseea@php.net>
6: --FILE--
7: <?php
8: class pubf {
9: public $a;
10: static public $s;
11: }
12: class subpubf extends pubf {
13: }
14:
15: class protf {
16: protected $a;
17: static protected $s;
18: }
19: class subprotf extends protf {
20: }
21:
22: class privf {
23: private $a;
24: static protected $s;
25: }
26: class subprivf extends privf {
27: }
28:
29: $classes = array("pubf", "subpubf", "protf", "subprotf",
30: "privf", "subprivf");
31: foreach($classes as $class) {
32: echo "Reflecting on class $class: \n";
33: $rc = new ReflectionClass($class);
34: try {
35: echo " --> Check for s: ";
36: var_dump($rc->getProperty("s"));
37: } catch (exception $e) {
38: echo $e->getMessage() . "\n";
39: }
40: try {
41: echo " --> Check for a: ";
42: var_dump($rc->getProperty("a"));
43: } catch (exception $e) {
44: echo $e->getMessage() . "\n";
45: }
46: try {
47: echo " --> Check for A: ";
48: var_dump($rc->getProperty("A"));
49: } catch (exception $e) {
50: echo $e->getMessage() . "\n";
51: }
52: try {
53: echo " --> Check for doesntExist: ";
54: var_dump($rc->getProperty("doesntExist"));
55: } catch (exception $e) {
56: echo $e->getMessage() . "\n";
57: }
58:
59: }
60: ?>
61: --EXPECTF--
62: Reflecting on class pubf:
63: --> Check for s: object(ReflectionProperty)#%d (2) {
64: [%u|b%"name"]=>
65: %unicode|string%(1) "s"
66: [%u|b%"class"]=>
67: %unicode|string%(4) "pubf"
68: }
69: --> Check for a: object(ReflectionProperty)#%d (2) {
70: [%u|b%"name"]=>
71: %unicode|string%(1) "a"
72: [%u|b%"class"]=>
73: %unicode|string%(4) "pubf"
74: }
75: --> Check for A: Property A does not exist
76: --> Check for doesntExist: Property doesntExist does not exist
77: Reflecting on class subpubf:
78: --> Check for s: object(ReflectionProperty)#%d (2) {
79: [%u|b%"name"]=>
80: %unicode|string%(1) "s"
81: [%u|b%"class"]=>
82: %unicode|string%(4) "pubf"
83: }
84: --> Check for a: object(ReflectionProperty)#%d (2) {
85: [%u|b%"name"]=>
86: %unicode|string%(1) "a"
87: [%u|b%"class"]=>
88: %unicode|string%(4) "pubf"
89: }
90: --> Check for A: Property A does not exist
91: --> Check for doesntExist: Property doesntExist does not exist
92: Reflecting on class protf:
93: --> Check for s: object(ReflectionProperty)#%d (2) {
94: [%u|b%"name"]=>
95: %unicode|string%(1) "s"
96: [%u|b%"class"]=>
97: %unicode|string%(5) "protf"
98: }
99: --> Check for a: object(ReflectionProperty)#%d (2) {
100: [%u|b%"name"]=>
101: %unicode|string%(1) "a"
102: [%u|b%"class"]=>
103: %unicode|string%(5) "protf"
104: }
105: --> Check for A: Property A does not exist
106: --> Check for doesntExist: Property doesntExist does not exist
107: Reflecting on class subprotf:
108: --> Check for s: object(ReflectionProperty)#%d (2) {
109: [%u|b%"name"]=>
110: %unicode|string%(1) "s"
111: [%u|b%"class"]=>
112: %unicode|string%(5) "protf"
113: }
114: --> Check for a: object(ReflectionProperty)#%d (2) {
115: [%u|b%"name"]=>
116: %unicode|string%(1) "a"
117: [%u|b%"class"]=>
118: %unicode|string%(5) "protf"
119: }
120: --> Check for A: Property A does not exist
121: --> Check for doesntExist: Property doesntExist does not exist
122: Reflecting on class privf:
123: --> Check for s: object(ReflectionProperty)#%d (2) {
124: [%u|b%"name"]=>
125: %unicode|string%(1) "s"
126: [%u|b%"class"]=>
127: %unicode|string%(5) "privf"
128: }
129: --> Check for a: object(ReflectionProperty)#%d (2) {
130: [%u|b%"name"]=>
131: %unicode|string%(1) "a"
132: [%u|b%"class"]=>
133: %unicode|string%(5) "privf"
134: }
135: --> Check for A: Property A does not exist
136: --> Check for doesntExist: Property doesntExist does not exist
137: Reflecting on class subprivf:
138: --> Check for s: object(ReflectionProperty)#%d (2) {
139: [%u|b%"name"]=>
140: %unicode|string%(1) "s"
141: [%u|b%"class"]=>
142: %unicode|string%(5) "privf"
143: }
144: --> Check for a: Property a does not exist
145: --> Check for A: Property A does not exist
146: --> Check for doesntExist: Property doesntExist does not exist
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>