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
// test: __invoke with Generator return type resolves item type in foreach // feature: completion // Adapted from phpactor call-expression/invoke2.test // expect: format( --- <?php class Foobar { /** * @return \Generator<DateTime> */ public function __invoke(): \Generator { yield new DateTime(); } } class DateTime { public function format(string $f): string {} } class Baz { private Foobar $foo; public function __construct(Foobar $foo) { $this->foo = $foo; } public function baz(): void { foreach (($this->foo)() as $bar) { $bar-><> } } }