ID:               32745
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jason at amp-design dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: CentOS 3 / RHEL 3
 PHP Version:      5CVS-2005-04-18 (dev)
 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

$b = $this already creates an object-reference to $this. 
If you do a $b = &$this PHP couldn't detect that $b is the 
same as $this, that could be overwritten and this would 
lead to problems with the engine. 


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

[2005-04-18 17:45:56] jason at amp-design dot net

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

Reply via email to