diff options
Diffstat (limited to 'tests/classes/bug27504.phpt')
-rw-r--r-- | tests/classes/bug27504.phpt | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/tests/classes/bug27504.phpt b/tests/classes/bug27504.phpt index ba44806bfe..4e227a1075 100644 --- a/tests/classes/bug27504.phpt +++ b/tests/classes/bug27504.phpt @@ -2,27 +2,30 @@ Bug #27504 (call_user_func_array allows calling of private/protected methods) --FILE-- <?php - class foo { - function __construct () { - $this->bar('1'); - } - private function bar ( $param ) { - echo 'Called function foo:bar('.$param.')'."\n"; - } - } +class foo { + function __construct () { + $this->bar('1'); + } + private function bar ( $param ) { + echo 'Called function foo:bar('.$param.')'."\n"; + } +} - $foo = new foo(); +$foo = new foo(); - call_user_func_array( array( $foo , 'bar' ) , array( '2' ) ); +try { + call_user_func_array( array( $foo , 'bar' ) , array( '2' ) ); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + $foo->bar('3'); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} - $foo->bar('3'); ?> ---EXPECTF-- +--EXPECT-- Called function foo:bar(1) - -Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method foo::bar() in %s on line %d - -Fatal error: Uncaught Error: Call to private method foo::bar() from context '' in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d +call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method foo::bar() +Call to private method foo::bar() from context '' |