From: redeye at erisx dot de Operating system: Windows, Linux PHP version: 5.0.0b4 (beta4) PHP Bug Type: Zend Engine 2 problem Bug description: call_user_func_array allows calling of private/protected methods
Description: ------------ 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: --------------- <?php class foo { function __construct () { $this->bar('1'); } private function bar ( $param ) { echo 'Called function foo:bar('.$param.');<br>'; } } $foo = new foo(); call_user_func_array( array( $foo , 'bar' ) , array( '2' ) ); $foo->bar('3'); ?> 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 -- Edit bug report at http://bugs.php.net/?id=27504&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27504&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27504&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27504&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27504&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27504&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27504&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27504&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27504&r=support Expected behavior: http://bugs.php.net/fix.php?id=27504&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27504&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27504&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27504&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27504&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27504&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27504&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27504&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27504&r=float