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

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

update php

File size: 649 bytes
Line 
1--TEST--
2iterable type#001
3--FILE--
4<?php
5
6function test(iterable $iterable) {
7    var_dump($iterable);
8}
9
10function gen() {
11    yield 1;
12    yield 2;
13    yield 3;
14};
15
16test([1, 2, 3]);
17test(gen());
18test(new ArrayIterator([1, 2, 3]));
19
20try {
21    test(1);
22} catch (Throwable $e) {
23    echo $e->getMessage();
24}
25
26--EXPECTF--
27array(3) {
28  [0]=>
29  int(1)
30  [1]=>
31  int(2)
32  [2]=>
33  int(3)
34}
35object(Generator)#1 (0) {
36}
37object(ArrayIterator)#1 (1) {
38  ["storage":"ArrayIterator":private]=>
39  array(3) {
40    [0]=>
41    int(1)
42    [1]=>
43    int(2)
44    [2]=>
45    int(3)
46  }
47}
48Argument 1 passed to test() must be iterable, integer given, called in %s on line %d
Note: See TracBrowser for help on using the repository browser.