Edit report at http://bugs.php.net/bug.php?id=54358&edit=1
ID: 54358 Updated by: [email protected] Reported by: frederic dot hardy at mageekbox dot net Summary: Closure, use and reference -Status: Assigned +Status: Closed Type: Bug Package: Scripting Engine problem PHP Version: 5.3.6 Assigned To: dmitry Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-04-08 12:02:09] [email protected] Automatic comment from SVN on behalf of dmitry Revision: http://svn.php.net/viewvc/?view=revision&revision=310050 Log: - Fixed bug #54358 (Closure, use and reference) - Fixed bug #54039 (use() of static variables in lambda functions can break staticness) ------------------------------------------------------------------------ [2011-03-23 11:03:37] frederic dot hardy at mageekbox dot net Trunck version is not affected by this bug. ------------------------------------------------------------------------ [2011-03-23 10:56:19] frederic dot hardy at mageekbox dot net Description: ------------ When the same variable is 'used' by one closure by reference, and an another closure 'uses' the same variable by value several time, the variable value is corrupted. This bub seems to be related to http://bugs.php.net/53958 which is closed since PHP 5.3.6. Test script: --------------- <?php class asserter { public function call($function) {} } $asserter = new asserter(); $closure = function() use ($asserter, & $function) { $asserter->call($function = uniqid()); }; try { $closure(); } catch (\exception $exception) { } var_dump($function); $function = 'md5'; $closure = function() use ($asserter, $function) { $asserter->call($function); }; try { $closure(); } catch (\exception $exception) { } var_dump($function); $closure = function() use ($asserter, $function) { $asserter->call($function); }; try { $closure(); } catch (\exception $exception) {} var_dump($function); ?> Expected result: ---------------- string(13) "4d89c1bc241ff" string(3) "md5" string(3) "md5" Actual result: -------------- string(13) "4d89c1bc241ff" string(3) "md5" string(3) �a" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54358&edit=1
