|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27504 call_user_func_array allows calling of private/protected methods
Submitted: 2004-03-05 03:21 UTC Modified: 2004-03-14 12:53 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: redeye at erisx dot de Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-03-05 OS: *
Private report: No CVE-ID: None
 [2004-03-05 03:21 UTC] redeye at erisx dot de
Using call_user_func_array you are able to call a private or protected method of any object. I think this should not be allowed as it will lead to bad programming style as you could use this bug to access methods which should be hidden.

Reproduce code:

    class foo {
        function __construct () {
        private function bar ( $param ) {
            echo 'Called function foo:bar('.$param.');<br>';

    $foo = new foo();

    call_user_func_array( array( $foo , 'bar' ) , array( '2' ) );



Expected result:
Called function foo:bar(1);

Fatal error: Call to private method foo::bar() from context '' in /www/htdocs/bug.php on line 14

Actual result:
Called function foo:bar(1);
Called function foo:bar(2);

Fatal error: Call to private method foo::bar() from context '' in /www/htdocs/bug.php on line 17


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-05 03:37 UTC]
Please try using this CVS snapshot:
For Windows:
 [2004-03-05 07:00 UTC] redeye at erisx dot de
Still the same results ( using the latest snapshot )
 [2004-03-05 07:06 UTC]
Andi, worth fixing this? :)
 [2004-03-14 12:53 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 07:05:46 2022 UTC