summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/iterable_003.phpt
blob: eda77d490b6482eeff9a061a478e7ea5bc17619b (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#003 - Return types
--FILE--
<?php

function foo(): iterable {
    return [];
}
function bar(): iterable {
    return (function () { yield; })();
}

function baz(): iterable {
    return 1;
}

var_dump(foo());
var_dump(bar());

try {
    baz();
} catch (Throwable $e) {
    echo $e->getMessage();
}

?>
--EXPECT--
array(0) {
}
object(Generator)#2 (0) {
}
Return value of baz() must be of type iterable, int returned