1--TEST--
2Observer: Generator with manual traversal
3--SKIPIF--
4<?php if (!extension_loaded('zend-test')) die('skip: zend-test extension required'); ?>
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.observe_all=1
8zend_test.observer.show_return_value=1
9--FILE--
10<?php
11function fooResults() {
12    echo 'Starting generator' . PHP_EOL;
13    $i = 0;
14    while (true) {
15        if (yield $i++) break;
16    }
17}
18
19function doSomething() {
20    $generator = fooResults();
21
22    while($generator->current() !== NULL) {
23        echo $generator->current() . PHP_EOL;
24        if ($generator->current() === 5) {
25            $generator->send('Boop');
26        }
27        $generator->next();
28    }
29
30    return 'Done';
31}
32
33echo doSomething() . PHP_EOL;
34?>
35--EXPECTF--
36<!-- init '%s%eobserver_generator_%d.php' -->
37<file '%s%eobserver_generator_%d.php'>
38  <!-- init doSomething() -->
39  <doSomething>
40    <!-- init fooResults() -->
41    <fooResults>
42Starting generator
43    </fooResults:0>
440
45    <fooResults>
46    </fooResults:1>
471
48    <fooResults>
49    </fooResults:2>
502
51    <fooResults>
52    </fooResults:3>
533
54    <fooResults>
55    </fooResults:4>
564
57    <fooResults>
58    </fooResults:5>
595
60    <fooResults>
61    </fooResults:NULL>
62  </doSomething:'Done'>
63Done
64</file '%s%eobserver_generator_%d.php'>
65