Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionClass::implementsInterface()
3: --CREDITS--
4: Robin Fernandes <robinf@php.net>
5: Steve Seear <stevseea@php.net>
6: --FILE--
7: <?php
8: interface I1 {}
9: class A implements I1 {}
10: class B extends A {}
11:
12: interface I2 extends I1 {}
13: class C implements I2 {}
14:
15: $classNames = array('A', 'B', 'C', 'I1', 'I2');
16:
17: foreach ($classNames as $className) {
18: $rcs[$className] = new ReflectionClass($className);
19: }
20:
21: foreach ($rcs as $childName => $child) {
22: foreach ($rcs as $parentName => $parent) {
23: echo "Does " . $childName . " implement " . $parentName . "? \n";
24: echo " - Using object argument: ";
25: try {
26: var_dump($child->implementsInterface($parent));
27: } catch (Exception $e) {
28: echo $e->getMessage() . "\n";
29: }
30: echo " - Using string argument: ";
31: try {
32: var_dump($child->implementsInterface($parentName));
33: } catch (Exception $e) {
34: echo $e->getMessage() . "\n";
35: }
36: }
37: }
38:
39:
40:
41: echo "\n\nTest bad arguments:\n";
42: try {
43: var_dump($rcs['A']->implementsInterface());
44: } catch (Exception $e) {
45: echo $e->getMessage() . "\n";
46: }
47: try {
48: var_dump($rcs['A']->implementsInterface('C', 'C'));
49: } catch (Exception $e) {
50: echo $e->getMessage() . "\n";
51: }
52: try {
53: var_dump($rcs['A']->implementsInterface(null));
54: } catch (Exception $e) {
55: echo $e->getMessage() . "\n";
56: }
57: try {
58: var_dump($rcs['A']->implementsInterface('ThisClassDoesNotExist'));
59: } catch (Exception $e) {
60: echo $e->getMessage() . "\n";
61: }
62: try {
63: var_dump($rcs['A']->implementsInterface(2));
64: } catch (Exception $e) {
65: echo $e->getMessage() . "\n";
66: }
67: ?>
68: --EXPECTF--
69: Does A implement A?
70: - Using object argument: Interface A is a Class
71: - Using string argument: Interface A is a Class
72: Does A implement B?
73: - Using object argument: Interface B is a Class
74: - Using string argument: Interface B is a Class
75: Does A implement C?
76: - Using object argument: Interface C is a Class
77: - Using string argument: Interface C is a Class
78: Does A implement I1?
79: - Using object argument: bool(true)
80: - Using string argument: bool(true)
81: Does A implement I2?
82: - Using object argument: bool(false)
83: - Using string argument: bool(false)
84: Does B implement A?
85: - Using object argument: Interface A is a Class
86: - Using string argument: Interface A is a Class
87: Does B implement B?
88: - Using object argument: Interface B is a Class
89: - Using string argument: Interface B is a Class
90: Does B implement C?
91: - Using object argument: Interface C is a Class
92: - Using string argument: Interface C is a Class
93: Does B implement I1?
94: - Using object argument: bool(true)
95: - Using string argument: bool(true)
96: Does B implement I2?
97: - Using object argument: bool(false)
98: - Using string argument: bool(false)
99: Does C implement A?
100: - Using object argument: Interface A is a Class
101: - Using string argument: Interface A is a Class
102: Does C implement B?
103: - Using object argument: Interface B is a Class
104: - Using string argument: Interface B is a Class
105: Does C implement C?
106: - Using object argument: Interface C is a Class
107: - Using string argument: Interface C is a Class
108: Does C implement I1?
109: - Using object argument: bool(true)
110: - Using string argument: bool(true)
111: Does C implement I2?
112: - Using object argument: bool(true)
113: - Using string argument: bool(true)
114: Does I1 implement A?
115: - Using object argument: Interface A is a Class
116: - Using string argument: Interface A is a Class
117: Does I1 implement B?
118: - Using object argument: Interface B is a Class
119: - Using string argument: Interface B is a Class
120: Does I1 implement C?
121: - Using object argument: Interface C is a Class
122: - Using string argument: Interface C is a Class
123: Does I1 implement I1?
124: - Using object argument: bool(true)
125: - Using string argument: bool(true)
126: Does I1 implement I2?
127: - Using object argument: bool(false)
128: - Using string argument: bool(false)
129: Does I2 implement A?
130: - Using object argument: Interface A is a Class
131: - Using string argument: Interface A is a Class
132: Does I2 implement B?
133: - Using object argument: Interface B is a Class
134: - Using string argument: Interface B is a Class
135: Does I2 implement C?
136: - Using object argument: Interface C is a Class
137: - Using string argument: Interface C is a Class
138: Does I2 implement I1?
139: - Using object argument: bool(true)
140: - Using string argument: bool(true)
141: Does I2 implement I2?
142: - Using object argument: bool(true)
143: - Using string argument: bool(true)
144:
145:
146: Test bad arguments:
147:
148: Warning: ReflectionClass::implementsInterface() expects exactly 1 parameter, 0 given in %s on line 37
149: NULL
150:
151: Warning: ReflectionClass::implementsInterface() expects exactly 1 parameter, 2 given in %s on line 42
152: NULL
153: Parameter one must either be a string or a ReflectionClass object
154: Interface ThisClassDoesNotExist does not exist
155: Parameter one must either be a string or a ReflectionClass object
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>