1--TEST--
2ReflectionGenerator basic test
3--FILE--
4<?php
5
6function foo() {
7    yield;
8}
9
10$gens = [
11    (new class() {
12        function a() {
13            yield from foo();
14        }
15    })->a(),
16    (function() {
17        yield;
18    })(),
19    foo(),
20];
21
22foreach ($gens as $gen) {
23    var_dump($gen);
24
25    $gen->valid(); // start Generator
26    $ref = new ReflectionGenerator($gen);
27
28    var_dump($ref->getTrace());
29    var_dump($ref->getExecutingLine());
30    var_dump($ref->getExecutingFile());
31    var_dump($ref->getExecutingGenerator());
32    var_dump($ref->getFunction());
33    var_dump($ref->getThis());
34}
35
36?>
37--EXPECTF--
38object(Generator)#2 (0) {
39}
40array(2) {
41  [0]=>
42  array(4) {
43    ["file"]=>
44    string(%d) "%s"
45    ["line"]=>
46    int(%d)
47    ["function"]=>
48    string(3) "foo"
49    ["args"]=>
50    array(0) {
51    }
52  }
53  [1]=>
54  array(5) {
55    ["function"]=>
56    string(1) "a"
57    ["class"]=>
58    string(%d) "class@anonymous%s"
59    ["object"]=>
60    object(class@anonymous)#%d (0) {
61    }
62    ["type"]=>
63    string(2) "->"
64    ["args"]=>
65    array(0) {
66    }
67  }
68}
69int(%d)
70string(%d) "%sReflectionGenerator_basic.%s"
71object(Generator)#6 (0) {
72}
73object(ReflectionMethod)#8 (2) {
74  ["name"]=>
75  string(1) "a"
76  ["class"]=>
77  string(%d) "class@anonymous%s"
78}
79object(class@anonymous)#1 (0) {
80}
81object(Generator)#4 (0) {
82}
83array(1) {
84  [0]=>
85  array(2) {
86    ["function"]=>
87    string(9) "{closure}"
88    ["args"]=>
89    array(0) {
90    }
91  }
92}
93int(%d)
94string(%d) "%sReflectionGenerator_basic.%s"
95object(Generator)#4 (0) {
96}
97object(ReflectionFunction)#7 (1) {
98  ["name"]=>
99  string(9) "{closure}"
100}
101NULL
102object(Generator)#5 (0) {
103}
104array(1) {
105  [0]=>
106  array(2) {
107    ["function"]=>
108    string(3) "foo"
109    ["args"]=>
110    array(0) {
111    }
112  }
113}
114int(%d)
115string(%d) "%sReflectionGenerator_basic.%s"
116object(Generator)#5 (0) {
117}
118object(ReflectionFunction)#8 (1) {
119  ["name"]=>
120  string(3) "foo"
121}
122NULL
123