xref: /PHP-7.0/tests/classes/bug27504.phpt (revision e97d5fab)
1--TEST--
2Bug #27504 (call_user_func_array allows calling of private/protected methods)
3--FILE--
4<?php
5	class foo {
6		function __construct () {
7			$this->bar('1');
8		}
9		private function bar ( $param ) {
10			echo 'Called function foo:bar('.$param.')'."\n";
11		}
12	}
13
14	$foo = new foo();
15
16	call_user_func_array( array( $foo , 'bar' ) , array( '2' ) );
17
18	$foo->bar('3');
19?>
20--EXPECTF--
21Called function foo:bar(1)
22
23Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method foo::bar() in %s on line %d
24
25Fatal error: Uncaught Error: Call to private method foo::bar() from context '' in %s:%d
26Stack trace:
27#0 {main}
28  thrown in %s on line %d
29