Bug #62135 [NEW]: Closure->bindTo plus $this reassign = corruption
| From: | Sjon at hortensius dot net | Date: | Thu, 24 May 2012 09:25:58 +0000 |
| Subject: | Bug #62135 [NEW]: Closure->bindTo plus $this reassign = corruption | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-170757@lists.php.net to get a copy of this message | ||
From: Sjon at hortensius dot net
Operating system: ArchLinux
PHP version: 5.4.3
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Closure->bindTo plus $this reassign = corruption
Description:
------------
I just found the bindTo method on a Closure, a started to play with it. I
found
out I can get some serieusly strange behaviour by re-assigning $this.
Somehow I
end up with one variable pointing to different objects?
Test script:
---------------
From: http://3v4l.org/bp598#v540
<?php
class A
{
public $a = 'public';
}
$m = function (){
$x =& $this;
$x = new stdClass;
var_dump($this, $this->a);
};
$a = new A;
$m = $m->bindTo($a);
$m();
Expected result:
----------------
* Cannot re-assign $this OR
* 'stdClass' + Notice OR
* 'A' + 'public
Actual result:
--------------
object(stdClass)#1 (0) {
}
string(6) "public"
--
Edit bug report at https://bugs.php.net/bug.php?id=62135&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62135&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62135&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62135&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62135&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62135&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62135&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62135&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62135&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62135&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62135&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62135&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62135&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62135&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62135&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62135&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62135&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62135&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62135&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62135&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62135&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62135&r=mysqlcfg