source: src/router/php7/Zend/tests/type_declarations/iterable_005.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 6 weeks ago

update php

File size: 578 bytes
Line 
1--TEST--
2iterable type#005 - Return type covariance
3--FILE--
4<?php
5
6class Test {
7    function method(): iterable {
8        return [];
9    }
10}
11
12class TestArray extends Test {
13    function method(): array {
14        return [];
15    }
16}
17
18class TestTraversable extends Test {
19    function method(): Traversable {
20        return new ArrayIterator([]);
21    }
22}
23
24class TestScalar extends Test {
25    function method(): int {
26        return 1;
27    }
28}
29
30?>
31--EXPECTF--
32
33Fatal error: Declaration of TestScalar::method(): int must be compatible with Test::method(): iterable in %s on line %d
Note: See TracBrowser for help on using the repository browser.