summaryrefslogtreecommitdiff
path: root/Zend/tests/call_user_func_001.phpt
blob: a6e43f30605a870d5bf4724d6cafd75876728fa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--TEST--
Testing call_user_func inside namespace
--FILE--
<?php

namespace testing {
	function foobar($str) {
		var_dump($str);
	}

	abstract class bar {
		protected function prot($str) {
			print "Shouldn't be called!\n";
		}
	}
	class foo extends bar {
		private function priv($str) {
			print "Shouldn't be called!\n";
		}
	}

	call_user_func(__NAMESPACE__ .'\foobar', 'foobar');

	$class =  __NAMESPACE__ .'\foo';
    try {
        call_user_func(array(new $class, 'priv'), 'foobar');
    } catch (\TypeError $e) {
        echo $e->getMessage(), "\n";
    }
	try {
        call_user_func(array(new $class, 'prot'), 'foobar');
    } catch (\TypeError $e) {
        echo $e->getMessage(), "\n";
    }
}

?>
--EXPECT--
string(6) "foobar"
call_user_func() expects parameter 1 to be a valid callback, cannot access private method testing\foo::priv()
call_user_func() expects parameter 1 to be a valid callback, cannot access protected method testing\foo::prot()