summaryrefslogtreecommitdiff
path: root/Zend/tests/return_types/generators005.phpt
blob: a7e3bda042206a9da72ced45fa7d99148ad8170b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--TEST--
Return type covariance works with generators
--FILE--
<?php
interface Collection extends IteratorAggregate {
    function getIterator(): Iterator;
}

class SomeCollection implements Collection {
    function getIterator(): Iterator {
        foreach ($this->data as $key => $value) {
            yield $key => $value;
        }
    }
}

$some = new SomeCollection();
var_dump($some->getIterator());
--EXPECTF--
object(Generator)#%d (%d) {
}