xref: /PHP-7.1/Zend/tests/method_exists_002.phpt (revision 7af945e2)
1--TEST--
2Testing method_exists()
3--FILE--
4<?php
5
6class bar {
7	static public function stat_a2() {
8	}
9	static private function stat_b2() {
10	}
11	static protected function stat_c2() {
12	}
13
14	private function method_a() {
15	}
16	protected function method_b() {
17	}
18	public function method_c() {
19	}
20}
21
22
23
24class baz extends bar {
25	static public function stat_a() {
26	}
27	static private function stat_b() {
28	}
29	static protected function stat_c() {
30	}
31
32	private function method_a() {
33	}
34	protected function method_b() {
35	}
36	public function method_c() {
37	}
38}
39
40var_dump(method_exists('baz', 'stat_a'));
41var_dump(method_exists('baz', 'stat_b'));
42var_dump(method_exists('baz', 'stat_c'));
43print "----\n";
44var_dump(method_exists('baz', 'stat_a2'));
45var_dump(method_exists('baz', 'stat_b2'));
46var_dump(method_exists('baz', 'stat_c2'));
47print "----\n";
48
49$baz = new baz;
50var_dump(method_exists($baz, 'method_a'));
51var_dump(method_exists($baz, 'method_b'));
52var_dump(method_exists($baz, 'method_c'));
53print "----\n";
54var_dump(method_exists($baz, 'stat_a'));
55var_dump(method_exists($baz, 'stat_b'));
56var_dump(method_exists($baz, 'stat_c'));
57
58?>
59--EXPECT--
60bool(true)
61bool(true)
62bool(true)
63----
64bool(true)
65bool(true)
66bool(true)
67----
68bool(true)
69bool(true)
70bool(true)
71----
72bool(true)
73bool(true)
74bool(true)
75