1--TEST--
2method_exists() on userspace classes; static & non-static methods with various visibilities.
3--FILE--
4<?php
5Class B {
6    public function inherit_pub() {}
7    protected function inherit_prot() {}
8    private function inherit_priv() {}
9    static public function inherit_static_pub() {}
10    static protected function inherit_static_prot() {}
11    static private function inherit_static_priv() {}
12}
13
14Class C extends B {
15    public function pub() {}
16    protected function prot() {}
17    private function priv() {}
18    static public function static_pub() {}
19    static protected function static_prot() {}
20    static private function static_priv() {}
21}
22
23
24$methods = array(
25    'inherit_pub', 'inherit_prot', 'inherit_priv',
26    'inherit_static_pub', 'inherit_static_prot', 'inherit_static_priv',
27    'pub', 'prot', 'priv',
28    'static_pub', 'static_prot', 'static_priv',
29    'non_existent');
30
31echo "\n ---(Using string class name)---\n";
32foreach ($methods as $method) {
33  echo "Does C::$method exist? ";
34  var_dump(method_exists("C", $method));
35}
36
37echo "\n ---(Using object)---\n";
38$myC = new C;
39foreach ($methods as $method) {
40  echo "Does C::$method exist? ";
41  var_dump(method_exists($myC, $method));
42}
43
44echo "Done";
45?>
46--EXPECT--
47---(Using string class name)---
48Does C::inherit_pub exist? bool(true)
49Does C::inherit_prot exist? bool(true)
50Does C::inherit_priv exist? bool(false)
51Does C::inherit_static_pub exist? bool(true)
52Does C::inherit_static_prot exist? bool(true)
53Does C::inherit_static_priv exist? bool(false)
54Does C::pub exist? bool(true)
55Does C::prot exist? bool(true)
56Does C::priv exist? bool(true)
57Does C::static_pub exist? bool(true)
58Does C::static_prot exist? bool(true)
59Does C::static_priv exist? bool(true)
60Does C::non_existent exist? bool(false)
61
62 ---(Using object)---
63Does C::inherit_pub exist? bool(true)
64Does C::inherit_prot exist? bool(true)
65Does C::inherit_priv exist? bool(true)
66Does C::inherit_static_pub exist? bool(true)
67Does C::inherit_static_prot exist? bool(true)
68Does C::inherit_static_priv exist? bool(true)
69Does C::pub exist? bool(true)
70Does C::prot exist? bool(true)
71Does C::priv exist? bool(true)
72Does C::static_pub exist? bool(true)
73Does C::static_prot exist? bool(true)
74Does C::static_priv exist? bool(true)
75Does C::non_existent exist? bool(false)
76Done
77