|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-06-29 20:50 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2016-06-29 20:50 UTC] nikic@php.net
[2016-06-29 21:06 UTC] trowski@php.net
[2016-06-30 00:27 UTC] bwoebi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ iterator_to_array() does not add all values yielded from a generator if yield from is used in the generator. Test script: --------------- <?php function gen1() { yield 1; yield from gen2(); yield 5; } function gen2() { yield 2; yield 3; yield 4; } print_r(iterator_to_array(gen1(), true)); $result = []; foreach (gen1() as $yielded) { $result[] = $yielded; } print_r($result); Expected result: ---------------- Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Actual result: -------------- Array ( [0] => 2 [1] => 5 [2] => 4 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )