From: dkr at mindwerk dot de Operating system: linux 2.6.21 PHP version: 5.2.11 PHP Bug Type: Class/Object related Bug description: non static class calls inside of objects will cause a fake __call
Description: ------------ I don't really understand the following situation.. Made some comments in the code to explain it. There is something wrong with class and Object scopes: calling a non-static function of another class inside an object will cause __call (in dependence of existence in the other class) to different behaviors when using self:: instead of __CLASS__ in the non-static method. Reproduce code: --------------- <?php class Foo { function __call($f,$a) { die("__called!\n"); } function write($text) { echo($text); } // defining debug as static will cause // the whole thing to work properly function debug($text) { return call_user_func_array( // "self" acts like making a lookup in // class Bar, fails and then runs the // magic method in this class, but why? // i dont have extended the Bar class... // __CLASS__ will work, but dont work for // extended classes, as self should do it array(self,'write'), array($text,1) ); } } class Bar { function __construct() { Foo::debug("foobar\n"); } // uncomment the following to make Foo::debug() // throw the text foobar, ehm? note that we do NOT // echo any content here... that is something like // inheritance it should not do? will echo "foobar".. /* function __call($f,$a) { } */ } $bar = new Bar(); // will cause php to die Expected result: ---------------- foobar Actual result: -------------- __called! -- Edit bug report at http://bugs.php.net/?id=50380&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50380&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50380&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50380&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50380&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50380&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50380&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50380&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50380&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50380&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50380&r=support Expected behavior: http://bugs.php.net/fix.php?id=50380&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50380&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50380&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50380&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50380&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50380&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50380&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50380&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50380&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50380&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50380&r=mysqlcfg