From:             pterjan at linuxfr dot org
Operating system: GNU/Linux
PHP version:      4.3.8
PHP Bug Type:     Class/Object related
Bug description:  $this is caller inside class methods

Description:
------------
When a method is called outside any instance, I would expect $this not
being defined, however, if the method is called from another object, it
will point to the caller.
Is it intended ?

Reproduce code:
---------------
<?php
        class Plop {
                function coin(){
                        echo get_class($this);
                }
        }
        class Foo {
                function plop(){
                        Plop::coin();
                }
        }
        $foo =& new Foo();
        $foo->plop();
?>

Expected result:
----------------
Nothing

Actual result:
--------------
foo

-- 
Edit bug report at http://bugs.php.net/?id=29294&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29294&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29294&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29294&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29294&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29294&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29294&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29294&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29294&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29294&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29294&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29294&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29294&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29294&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29294&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29294&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29294&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29294&r=float

Reply via email to