Bug #70874 [NEW]: Closure binding does not work as expected.

From: Date: Sat, 07 Nov 2015 08:10:05 +0000
Subject: Bug #70874 [NEW]: Closure binding does not work as expected.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197092@lists.php.net to get a copy of this message
From: info at mbcraft dot it Operating system: Linux qwqw 3.13.0-66-generic #10 PHP version: 5.5.30 Package: Reflection related Bug Type: Bug Bug description:Closure binding does not work as expected. Description: ------------ The closure is simply not rebound as described by the language specification using the bindTo function. Test script: --------------- <?php class A { private $my_string; public function __construct($st) { $this->my_string = $st; } public function launch() { return function() { echo $this->my_string."\n"; }; } } $a = new A("go"); $fn = $a->launch(); $fn(); $a2 = new A("ppppp"); $fn->bindTo($a2); $fn(); Expected result: ---------------- go ppppp Actual result: -------------- go go -- Edit bug report at https://bugs.php.net/bug.php?id=70874&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70874&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70874&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70874&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70874&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70874&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70874&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70874&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70874&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70874&r=support Expected behavior: https://bugs.php.net/fix.php?id=70874&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70874&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70874&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70874&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70874&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70874&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70874&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70874&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70874&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70874&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70874&r=mysqlcfg

« previous php.bugs (#197092) next »