#33537 [NEW]: assignment of $this to another var
| From: | bo at theaddedones dot com | Date: | Fri, 01 Jul 2005 15:47:46 +0000 |
| Subject: | #33537 [NEW]: assignment of $this to another var | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-81272@lists.php.net to get a copy of this message | ||
From: bo at theaddedones dot com
Operating system: OS X
PHP version: 5CVS-2005-07-01 (dev)
PHP Bug Type: Class/Object related
Bug description: assignment of $this to another var
Description:
------------
i can understand this error from inside a class
class Foo{
function bar(){
$this =& $something_else;
}
}
but i should think one can assign a ref to $this to another var.
class Foo{
function bar(){
$this_dupe =& $this; //fails to compile
$this_dupe = $this; //compiles okay
}
}
the reason i bring this up, is in php4 and 5.0 this is allowed .. if code
needs to run on php4 without silly performance hits (i.e. data copy on
assignment), would be nice to keep that.
from the error it seems it is trying to do this
$this =& $this_dupe .. but that is not what is being done
Reproduce code:
---------------
<?php
class Foo{
function bar(){
$this_dupe =& $this; //fails to compile
$this_dupe = $this; //works a okay
}
}
Expected result:
----------------
hopefully it should compile fine
Actual result:
--------------
Fatal error: Cannot re-assign $this in {test.php} on line 4
--
Edit bug report at http://bugs.php.net/?id=33537&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33537&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33537&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33537&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33537&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33537&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33537&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33537&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33537&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33537&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33537&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33537&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33537&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33537&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33537&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33537&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33537&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33537&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33537&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33537&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33537&r=mysqlcfg