summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
blob: a665d45c3073012d00841446281ade9faaee1ddc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--TEST--
ReflectionGenerator while being currently executed
--FILE--
<?php

function call(ReflectionGenerator $ref, $method, $rec = true) {
    if ($rec) {
        call($ref, $method, false);
        return;
    }
    var_dump($ref->$method());
}

function doCalls(ReflectionGenerator $ref) {
    call($ref, "getTrace");
    call($ref, "getExecutingLine");
    call($ref, "getExecutingFile");
    call($ref, "getExecutingGenerator");
    call($ref, "getFunction");
    call($ref, "getThis");
}

($gen = (function() use (&$gen) {
    $ref = new ReflectionGenerator($gen);

    doCalls($ref);

    yield from (function() use ($ref) {
        doCalls($ref);
        yield; // Generator !
    })();
})())->next();

?>
--EXPECTF--
array(0) {
}
int(%d)
string(%d) "%sReflectionGenerator_in_Generator.%s"
object(Generator)#2 (0) {
}
object(ReflectionFunction)#4 (1) {
  ["name"]=>
  string(9) "{closure}"
}
NULL
array(1) {
  [0]=>
  array(4) {
    ["file"]=>
    string(%d) "%s"
    ["line"]=>
    int(%d)
    ["function"]=>
    string(9) "{closure}"
    ["args"]=>
    array(0) {
    }
  }
}
int(%d)
string(%d) "%sReflectionGenerator_in_Generator.%s"
object(Generator)#5 (0) {
}
object(ReflectionFunction)#6 (1) {
  ["name"]=>
  string(9) "{closure}"
}
NULL