1--TEST--
2Generator::getReturn() success cases
3--FILE--
4<?php
5
6function gen1() {
7    return 42;
8    yield 24;
9}
10
11$gen = gen1();
12// Calling getReturn() directly here is okay due to auto-priming
13var_dump($gen->getReturn());
14
15function gen2() {
16    yield 24;
17    return 42;
18}
19
20$gen = gen2();
21var_dump($gen->current());
22$gen->next();
23var_dump($gen->getReturn());
24
25// & for generators specifies by-reference yield, not return
26// so it's okay to return a literal
27function &gen3() {
28    $var = 24;
29    yield $var;
30    return 42;
31}
32
33$gen = gen3();
34var_dump($gen->current());
35$gen->next();
36var_dump($gen->getReturn());
37
38// Return types for generators specify the return of the function,
39// not of the generator return value, so this code is okay
40function gen4() : Generator {
41    yield 24;
42    return 42;
43}
44
45$gen = gen4();
46var_dump($gen->current());
47$gen->next();
48var_dump($gen->getReturn());
49
50// Has no explicit return, but implicitly return NULL at the end
51function gen5() {
52    yield 24;
53}
54
55$gen = gen5();
56var_dump($gen->current());
57$gen->next();
58var_dump($gen->getReturn());
59
60// Explicit value-less return also results in a NULL generator
61// return value and there is no interference with type declarations
62function gen6() : Generator {
63    return;
64    yield 24;
65}
66
67$gen = gen6();
68var_dump($gen->getReturn());
69
70?>
71--EXPECT--
72int(42)
73int(24)
74int(42)
75int(24)
76int(42)
77int(24)
78int(42)
79int(24)
80NULL
81NULL
82