#36357 [NEW]: $tmp =& $this; is allowed!
| From: | dams@php.net | Date: | Fri, 10 Feb 2006 16:05:54 +0000 |
| Subject: | #36357 [NEW]: $tmp =& $this; is allowed! | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-93126@lists.php.net to get a copy of this message | ||
From: dams@php.net
Operating system: Any
PHP version: 5.1.2
PHP Bug Type: Class/Object related
Bug description: $tmp =& $this; is allowed!
Description:
------------
Using =&, it is possible to modify $this with the constructor.
This shouldn't be allowed, just like for
$tmp = $this;
Reproduce code:
---------------
<?php
class B {
function B() {
}
}
class A {
function A() {
$tmp =& $this;
var_dump($this); // outputs : object(A)
$tmp = new B();
var_dump($this); // outputs : object(B)
}
}
$a = new A();
var_dump($a); // outputs : object(A)
?>
Expected result:
----------------
object(A)#1 (0) {
}
object(A)#2 (0) {
}
object(A)#1 (0) {
}
// current result :
object(A)#1 (0) {
}
object(B)#2 (0) {
}
object(A)#1 (0) {
}
--
Edit bug report at http://bugs.php.net/?id=36357&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36357&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36357&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36357&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36357&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36357&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36357&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36357&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36357&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36357&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36357&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36357&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36357&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36357&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36357&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36357&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36357&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36357&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36357&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36357&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36357&r=mysqlcfg