From:             jason at amp-design dot net
Operating system: CentOS 3 / RHEL 3
PHP version:      5CVS-2005-04-18 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Incorrect reassignemeent of $this error

Description:
------------
An incorrect message about the reassignment of $this occurs in the 5.1.x
branches of PHP.

The code below doesn't product any errors...


<?php 
class A {}
$a = new A;
$b = &$a;
?>

but the "Reproduce code" produces an error when you are inside class
scope, trying to use the & operator to create a reference to $this.

Obviously the code $b = $this; does the exact same thing in PHP5, however
this is a problem as existing code (especially stuff written for PHP4 and
PHP5) will break. This is certainly the case here as this bug arises in
functions/imap_mailbox.php on line 25 of squirrel mail.

Please note this was tested using the php5-200504121430 build which is a
couple of days old now. I'm pretty sure it will remain in the latest
snapshot.

I have no idea why this comes up with the "reassigment of $this" error. I
would have thought this error would happen if the expression was reversed
to say $this = &$b.

Reproduce code:
---------------
<?php
class A {
        public function test() {
                $b = &$this;
        }
}
$a = new A;
$a->test();
?>

Expected result:
----------------
No output. $a is created and $b === $a during the scope of A::test() for
the given code above.

Actual result:
--------------
Fatal error: Cannot re-assign $this in /var/www/html/test.php on line 4

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

Reply via email to