Annotation of embedaddon/php/ext/standard/tests/class_object/method_exists_basic_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: method_exists() on userspace classes; static & non-static methods with various visibilities.
3: --FILE--
4: <?php
5: /* Prototype : proto bool is_subclass_of(object object, string class_name)
6: * Description: Returns true if the object has this class as one of its parents
7: * Source code: Zend/zend_builtin_functions.c
8: * Alias to functions:
9: */
10:
11: Class B {
12: public function inherit_pub() {}
13: protected function inherit_prot() {}
14: private function inherit_priv() {}
15: static public function inherit_static_pub() {}
16: static protected function inherit_static_prot() {}
17: static private function inherit_static_priv() {}
18: }
19:
20: Class C extends B {
21: public function pub() {}
22: protected function prot() {}
23: private function priv() {}
24: static public function static_pub() {}
25: static protected function static_prot() {}
26: static private function static_priv() {}
27: }
28:
29:
30: $methods = array(
31: 'inherit_pub', 'inherit_prot', 'inherit_priv',
32: 'inherit_static_pub', 'inherit_static_prot', 'inherit_static_priv',
33: 'pub', 'prot', 'priv',
34: 'static_pub', 'static_prot', 'static_priv',
35: 'non_existent');
36:
37: echo "\n ---(Using string class name)---\n";
38: foreach ($methods as $method) {
39: echo "Does C::$method exist? ";
40: var_dump(method_exists("C", $method));
41: }
42:
43: echo "\n ---(Using object)---\n";
44: $myC = new C;
45: foreach ($methods as $method) {
46: echo "Does C::$method exist? ";
47: var_dump(method_exists($myC, $method));
48: }
49:
50: echo "Done";
51: ?>
52: --EXPECTF--
53:
54: ---(Using string class name)---
55: Does C::inherit_pub exist? bool(true)
56: Does C::inherit_prot exist? bool(true)
57: Does C::inherit_priv exist? bool(true)
58: Does C::inherit_static_pub exist? bool(true)
59: Does C::inherit_static_prot exist? bool(true)
60: Does C::inherit_static_priv exist? bool(true)
61: Does C::pub exist? bool(true)
62: Does C::prot exist? bool(true)
63: Does C::priv exist? bool(true)
64: Does C::static_pub exist? bool(true)
65: Does C::static_prot exist? bool(true)
66: Does C::static_priv exist? bool(true)
67: Does C::non_existent exist? bool(false)
68:
69: ---(Using object)---
70: Does C::inherit_pub exist? bool(true)
71: Does C::inherit_prot exist? bool(true)
72: Does C::inherit_priv exist? bool(true)
73: Does C::inherit_static_pub exist? bool(true)
74: Does C::inherit_static_prot exist? bool(true)
75: Does C::inherit_static_priv exist? bool(true)
76: Does C::pub exist? bool(true)
77: Does C::prot exist? bool(true)
78: Does C::priv exist? bool(true)
79: Does C::static_pub exist? bool(true)
80: Does C::static_prot exist? bool(true)
81: Does C::static_priv exist? bool(true)
82: Does C::non_existent exist? bool(false)
83: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>