blob: 5502318e982a6e1755490114ae62d67749ad3987 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
--TEST--
Return type covariance works with generators
--FILE--
<?php
interface Collection extends IteratorAggregate {
function getIterator(): Iterator;
}
class SomeCollection implements Collection {
function getIterator(): Generator {
foreach ($this->data as $key => $value) {
yield $key => $value;
}
}
}
$some = new SomeCollection();
var_dump($some->getIterator());
--EXPECTF--
Fatal error: Declaration of SomeCollection::getIterator(): Generator must be compatible with Collection::getIterator(): Iterator in %sgenerators003.php on line 6
|