summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/iterable_005.phpt
blob: 39dede3b5c31a1877d317336fbaade7420de3a7d (plain)
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
--TEST--
iterable type#005 - Return type covariance
--FILE--
<?php

class Test {
    function method(): iterable {
        return [];
    }
}

class TestArray extends Test {
    function method(): array {
        return [];
    }
}

class TestTraversable extends Test {
    function method(): Traversable {
        return new ArrayIterator([]);
    }
}

class TestScalar extends Test {
    function method(): int {
        return 1;
    }
}

?>
--EXPECTF--
Fatal error: Declaration of TestScalar::method(): int must be compatible with Test::method(): iterable in %s on line %d