|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2013-06-10 13:55 UTC] laruence@php.net
-Assigned To:
+Assigned To: nikic
[2013-08-03 15:29 UTC] nikic@php.net
[2013-09-29 18:21 UTC] nikic@php.net
[2013-09-29 18:21 UTC] nikic@php.net
-Status: Assigned
+Status: Closed
[2013-11-17 09:30 UTC] laruence@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 21:00:01 2025 UTC |
Description: ------------ Each closure instance should have its own set of static variables. This works perfectly with non-generator closures (replace yield by return array in the test script), but not with generator closures (run the test script), where static variables seem to behave like a normal local variables. Test script: --------------- <?php function new_closure_gen() { return function() { static $foo = 0; //return array(++$foo); yield ++$foo; }; } $closure1 = new_closure_gen(); $closure2 = new_closure_gen(); $gen1 = $closure1(); $gen2 = $closure1(); $gen3 = $closure2(); foreach (array($gen1, $gen2, $gen3) as $gen) { foreach ($gen as $val) { print "$val\n"; } } Expected result: ---------------- 1 2 1 Actual result: -------------- 1 1 1