summaryrefslogtreecommitdiff
path: root/tests/classes/bug27504.phpt
blob: b6df46920adaf932041c73add18a64fd0849cb09 (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
--TEST--
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";
    }
}

$foo = new foo();

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";
}

?>
--EXPECT--
Called function foo:bar(1)
call_user_func_array(): Argument #1 ($function) must be a valid callback, cannot access private method foo::bar()
Call to private method foo::bar() from global scope