ID:               50380
 Updated by:       [email protected]
 Reported By:      dkr at mindwerk dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: linux 2.6.21
 PHP Version:      5.2.11
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

If you comment out the __call magic you'll get pretty clear error
message why and what goes wrong.


Previous Comments:
------------------------------------------------------------------------

[2009-12-04 09:11:12] dkr at mindwerk dot de

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 this bug report at http://bugs.php.net/?id=50380&edit=1

Reply via email to