xref: /php-ast/tests/type_hints.phpt (revision 260678d4)
1--TEST--
2Type hints
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10function test(
11    A $a, array $b, callable $c, INT $d, Float $e, string $f, bool $g, iterable $h
12) : void {
13}
14PHP;
15
16echo ast_dump(ast\parse_code($code, $version=70)), "\n";
17
18?>
19--EXPECTF--
20AST_STMT_LIST
21    0: AST_FUNC_DECL
22        name: "test"
23        docComment: null
24        params: AST_PARAM_LIST
25            0: AST_PARAM
26                type: AST_NAME
27                    flags: NAME_NOT_FQ (1)
28                    name: "A"
29                name: "a"
30                default: null
31            1: AST_PARAM
32                type: AST_TYPE
33                    flags: TYPE_ARRAY (7)
34                name: "b"
35                default: null
36            2: AST_PARAM
37                type: AST_TYPE
38                    flags: TYPE_CALLABLE (%d)
39                name: "c"
40                default: null
41            3: AST_PARAM
42                type: AST_TYPE
43                    flags: TYPE_LONG (4)
44                name: "d"
45                default: null
46            4: AST_PARAM
47                type: AST_TYPE
48                    flags: TYPE_DOUBLE (5)
49                name: "e"
50                default: null
51            5: AST_PARAM
52                type: AST_TYPE
53                    flags: TYPE_STRING (6)
54                name: "f"
55                default: null
56            6: AST_PARAM
57                type: AST_TYPE
58                    flags: TYPE_BOOL (%d)
59                name: "g"
60                default: null
61            7: AST_PARAM
62                type: AST_TYPE
63                    flags: TYPE_ITERABLE (%d)
64                name: "h"
65                default: null
66        stmts: AST_STMT_LIST
67        returnType: AST_TYPE
68            flags: TYPE_VOID (%d)
69        __declId: 0
70