Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionClass::hasMethod()
3: --CREDITS--
4: Robin Fernandes <robinf@php.net>
5: Steve Seear <stevseea@php.net>
6: --FILE--
7: <?php
8: class pubf {
9: public function f() {}
10: static public function s() {}
11: }
12: class subpubf extends pubf {
13: }
14:
15: class protf {
16: protected function f() {}
17: static protected function s() {}
18: }
19: class subprotf extends protf {
20: }
21:
22: class privf {
23: private function f() {}
24: static private function 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: echo " --> Check for f(): ";
35: var_dump($rc->hasMethod("f"));
36: echo " --> Check for s(): ";
37: var_dump($rc->hasMethod("s"));
38: echo " --> Check for F(): ";
39: var_dump($rc->hasMethod("F"));
40: echo " --> Check for doesntExist(): ";
41: var_dump($rc->hasMethod("doesntExist"));
42: }
43: ?>
44: --EXPECTF--
45: Reflecting on class pubf:
46: --> Check for f(): bool(true)
47: --> Check for s(): bool(true)
48: --> Check for F(): bool(true)
49: --> Check for doesntExist(): bool(false)
50: Reflecting on class subpubf:
51: --> Check for f(): bool(true)
52: --> Check for s(): bool(true)
53: --> Check for F(): bool(true)
54: --> Check for doesntExist(): bool(false)
55: Reflecting on class protf:
56: --> Check for f(): bool(true)
57: --> Check for s(): bool(true)
58: --> Check for F(): bool(true)
59: --> Check for doesntExist(): bool(false)
60: Reflecting on class subprotf:
61: --> Check for f(): bool(true)
62: --> Check for s(): bool(true)
63: --> Check for F(): bool(true)
64: --> Check for doesntExist(): bool(false)
65: Reflecting on class privf:
66: --> Check for f(): bool(true)
67: --> Check for s(): bool(true)
68: --> Check for F(): bool(true)
69: --> Check for doesntExist(): bool(false)
70: Reflecting on class subprivf:
71: --> Check for f(): bool(true)
72: --> Check for s(): bool(true)
73: --> Check for F(): bool(true)
74: --> Check for doesntExist(): bool(false)
75:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>