|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-18 20:15 UTC] johannes@php.net
[2005-04-19 16:15 UTC] jason at amp-design dot net
[2006-04-01 16:54 UTC] gavinfo@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 13:00:01 2025 UTC |
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