1--TEST-- 2Observer: Generator with manual traversal 3--EXTENSIONS-- 4zend_test 5--INI-- 6zend_test.observer.enabled=1 7zend_test.observer.show_output=1 8zend_test.observer.observe_all=1 9zend_test.observer.show_return_value=1 10--FILE-- 11<?php 12function fooResults() { 13 echo 'Starting generator' . PHP_EOL; 14 $i = 0; 15 while (true) { 16 if (yield $i++) break; 17 } 18} 19 20function doSomething() { 21 $generator = fooResults(); 22 23 while($generator->current() !== NULL) { 24 echo $generator->current() . PHP_EOL; 25 if ($generator->current() === 5) { 26 $generator->send('Boop'); 27 } 28 $generator->next(); 29 } 30 31 return 'Done'; 32} 33 34echo doSomething() . PHP_EOL; 35?> 36--EXPECTF-- 37<!-- init '%s%eobserver_generator_%d.php' --> 38<file '%s%eobserver_generator_%d.php'> 39 <!-- init doSomething() --> 40 <doSomething> 41 <!-- init fooResults() --> 42 <fooResults> 43Starting generator 44 </fooResults:0> 450 46 <fooResults> 47 </fooResults:1> 481 49 <fooResults> 50 </fooResults:2> 512 52 <fooResults> 53 </fooResults:3> 543 55 <fooResults> 56 </fooResults:4> 574 58 <fooResults> 59 </fooResults:5> 605 61 <fooResults> 62 </fooResults:NULL> 63 </doSomething:'Done'> 64Done 65</file '%s%eobserver_generator_%d.php'> 66