From:             ladislav dot prosek at matfyz dot cz
Operating system: Windows XP Pro
PHP version:      5.0.0RC2
PHP Bug Type:     Class/Object related
Bug description:  $this may be modified indirectly inside a method

Description:
------------
Trying to assign to $this inside a method results in:
"Fatal error: Cannot re-assign $this".

However, using a reference it is possible to modify $this.

Reproduce code:
---------------
class A
{
  function f()
  {
    $p =& $this;
    $p = "whatever";

    var_dump($this);

    // Note: accessing fields and invoking methods
    // via $this still works fine.
  }
};

$x = new A();
$x->f();


Expected result:
----------------
Fatal error: Cannot re-assign $this

Actual result:
--------------
string(8) "whatever"

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

Reply via email to