1--TEST--
2Methods can be generators
3--FILE--
4<?php
5
6class Test implements IteratorAggregate {
7    protected $data;
8
9    public function __construct(array $data) {
10        $this->data = $data;
11    }
12
13    public function getIterator(): Traversable {
14        foreach ($this->data as $value) {
15            yield $value;
16        }
17    }
18}
19
20$test = new Test(['foo', 'bar', 'baz']);
21foreach ($test as $value) {
22    var_dump($value);
23}
24
25?>
26--EXPECT--
27string(3) "foo"
28string(3) "bar"
29string(3) "baz"
30