summaryrefslogtreecommitdiff
path: root/Zend/tests/return_types/generators005.phpt
blob: 586e0ec0c85f8004ca2854bf8b7b3b3daae7876f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--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) {
}