From: claudio dot frizziero at nereal dot com Operating system: Linux (Fedora Core 4) PHP version: 5.0.5 PHP Bug Type: Scripting Engine problem Bug description: call_user_func and scope resolution operator ( :: )
Description: ------------ When I use call_user_func (and call_user_func_array, of course) inside a method to call a method of another class I'm expecting it works like the scope resolution operator. If it is not a bug: is it possible to add a flag, or alternatively add two similar function (i.e. call_user_func_Paamayim_Nekudotayim and call_user_func_array_Paamayim_Nekudotayim 8), to avoid the eval workaround? Thank you! Note: i'm using php 5.0.4, but I don't find any fix in the changelog to 5.0.5 Reproduce code: --------------- class MyClass { public $string = 'Hello!'; public function SayHello() { call_user_func(array('OutputClass', 'WriteToOutput')); // } public function SayHello2() { OutputClass::WriteToOutput(); } public function SayHello3($outputclass, $outputmethod) { // $outputclass::$outputmethod(); // syntax not allowed, with or without curly braces eval($outputclass . '::' . $outputmethod . '();'); // it works, but it's a workaround } } class OutputClass { public function WriteToOutput() { echo ($this->string); } } $a = new MyClass(); $a->SayHello(); // Fatal error: Using $this when not in object context $a->SayHello2(); // it works (wow!) $a->SayHello3('OutputClass', 'WriteToOutput'); // it works only using eval -- Edit bug report at http://bugs.php.net/?id=34690&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34690&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34690&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34690&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34690&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34690&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34690&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34690&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34690&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34690&r=support Expected behavior: http://bugs.php.net/fix.php?id=34690&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34690&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34690&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34690&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34690&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34690&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34690&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34690&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34690&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34690&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34690&r=mysqlcfg