Annotation of embedaddon/php/ext/reflection/tests/ReflectionMethod_basic3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionMethod class getName(), isInternal() and isUserDefined() methods
3: --FILE--
4: <?php
5:
6: function reflectMethod($class, $method) {
7: $methodInfo = new ReflectionMethod($class, $method);
8: echo "**********************************\n";
9: echo "Reflecting on method $class::$method()\n\n";
10: echo "\ngetName():\n";
11: var_dump($methodInfo->getName());
12: echo "\nisInternal():\n";
13: var_dump($methodInfo->isInternal());
14: echo "\nisUserDefined():\n";
15: var_dump($methodInfo->isUserDefined());
16: echo "\n**********************************\n";
17: }
18:
19: class TestClass
20: {
21: public function foo() {
22: echo "Called foo()\n";
23: }
24:
25: static function stat() {
26: echo "Called stat()\n";
27: }
28:
29: private function priv() {
30: echo "Called priv()\n";
31: }
32:
33: protected function prot() {}
34:
35: public function __destruct() {}
36: }
37:
38: class DerivedClass extends TestClass {}
39:
40: interface TestInterface {
41: public function int();
42: }
43:
44: reflectMethod("DerivedClass", "foo");
45: reflectMethod("TestClass", "stat");
46: reflectMethod("TestClass", "priv");
47: reflectMethod("TestClass", "prot");
48: reflectMethod("DerivedClass", "prot");
49: reflectMethod("TestInterface", "int");
50: reflectMethod("ReflectionProperty", "__construct");
51: reflectMethod("TestClass", "__destruct");
52:
53:
54: ?>
55: --EXPECT--
56: **********************************
57: Reflecting on method DerivedClass::foo()
58:
59:
60: getName():
61: string(3) "foo"
62:
63: isInternal():
64: bool(false)
65:
66: isUserDefined():
67: bool(true)
68:
69: **********************************
70: **********************************
71: Reflecting on method TestClass::stat()
72:
73:
74: getName():
75: string(4) "stat"
76:
77: isInternal():
78: bool(false)
79:
80: isUserDefined():
81: bool(true)
82:
83: **********************************
84: **********************************
85: Reflecting on method TestClass::priv()
86:
87:
88: getName():
89: string(4) "priv"
90:
91: isInternal():
92: bool(false)
93:
94: isUserDefined():
95: bool(true)
96:
97: **********************************
98: **********************************
99: Reflecting on method TestClass::prot()
100:
101:
102: getName():
103: string(4) "prot"
104:
105: isInternal():
106: bool(false)
107:
108: isUserDefined():
109: bool(true)
110:
111: **********************************
112: **********************************
113: Reflecting on method DerivedClass::prot()
114:
115:
116: getName():
117: string(4) "prot"
118:
119: isInternal():
120: bool(false)
121:
122: isUserDefined():
123: bool(true)
124:
125: **********************************
126: **********************************
127: Reflecting on method TestInterface::int()
128:
129:
130: getName():
131: string(3) "int"
132:
133: isInternal():
134: bool(false)
135:
136: isUserDefined():
137: bool(true)
138:
139: **********************************
140: **********************************
141: Reflecting on method ReflectionProperty::__construct()
142:
143:
144: getName():
145: string(11) "__construct"
146:
147: isInternal():
148: bool(true)
149:
150: isUserDefined():
151: bool(false)
152:
153: **********************************
154: **********************************
155: Reflecting on method TestClass::__destruct()
156:
157:
158: getName():
159: string(10) "__destruct"
160:
161: isInternal():
162: bool(false)
163:
164: isUserDefined():
165: bool(true)
166:
167: **********************************
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>