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