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

Last change on this file since 31874 was 31874, checked in by brainslayer, 2 months ago

update php

File size: 428 bytes
Line 
1--TEST--
2iterable type#003 - Return types
3--FILE--
4<?php
5
6function foo(): iterable {
7        return [];
8}
9function bar(): iterable {
10        return (function () { yield; })();
11}
12
13function baz(): iterable {
14    return 1;
15}
16
17var_dump(foo());
18var_dump(bar());
19
20try {
21    baz();
22} catch (Throwable $e) {
23    echo $e->getMessage();
24}
25
26?>
27--EXPECT--
28array(0) {
29}
30object(Generator)#2 (0) {
31}
32Return value of baz() must be iterable, integer returned
Note: See TracBrowser for help on using the repository browser.