Skip to content

Commit 1163e3c

Browse files
committed
add test stubs for Generator Return Types
1 parent 226dc41 commit 1163e3c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/PHPStan/Rules/Functions/data/missing-function-return-typehint.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,38 @@ function callableNestedNoPrototype() : callable{
148148
function callableNestedWithPrototype() : callable{
149149

150150
}
151+
152+
function returnsGeneratorOfIntegersNoPrototype(): \Generator
153+
{
154+
yield 1;
155+
yield 2;
156+
yield 3;
157+
}
158+
159+
/**
160+
* @return \Generator<int, int>
161+
*/
162+
function returnsGeneratorOfIntegersWithPrototype(): \Generator
163+
{
164+
yield 1;
165+
yield 2;
166+
yield 3;
167+
}
168+
169+
function returnsGeneratorOfIntegersByStringNoPrototype(): \Generator
170+
{
171+
yield '1' => 1;
172+
yield '2' => 2;
173+
yield '3' => 3;
174+
}
175+
176+
/**
177+
* @return \Generator<string, int>
178+
*/
179+
function returnsGeneratorOfIntegersByStringwithPrototype(): \Generator
180+
{
181+
yield '1' => 1;
182+
yield '2' => 2;
183+
yield '3' => 3;
184+
}
151185
}

0 commit comments

Comments
 (0)