1--TEST--
2Arrow functions and types ('fn($x) => $x') in PHP 7.4
3--SKIPIF--
4<?php if (PHP_VERSION_ID < 70400) die('skip PHP >= 7.4 only'); ?>
5--FILE--
6<?php
7
8require __DIR__ . '/../util.php';
9
10$code = <<<'PHP'
11<?php
12static fn() : int => 1;
13fn(iterable $i) : array => [$i];
14fn(stdClass $param) : \stdClass => $param;
15fn(\stdClass $param) : stdClass => $param;
16PHP;
17
18$node = ast\parse_code($code, $version=70);
19$version_70_repr = ast_dump($node);
20echo $version_70_repr . "\n";
21$node50 = ast\parse_code($code, $version=50);
22$version_50_repr = ast_dump($node50);
23echo "Same representation in version 50/70: ";
24var_export($version_50_repr == $version_70_repr);
25echo "\n";
26?>
27--EXPECTF--
28AST_STMT_LIST
29    0: AST_ARROW_FUNC
30        flags: MODIFIER_STATIC (%d)
31        name: "{closure}"
32        docComment: null
33        params: AST_PARAM_LIST
34        stmts: AST_RETURN
35            expr: 1
36        returnType: AST_TYPE
37            flags: TYPE_LONG (%d)
38        __declId: 0
39    1: AST_ARROW_FUNC
40        name: "{closure}"
41        docComment: null
42        params: AST_PARAM_LIST
43            0: AST_PARAM
44                type: AST_TYPE
45                    flags: TYPE_ITERABLE (%d)
46                name: "i"
47                default: null
48        stmts: AST_RETURN
49            expr: AST_ARRAY
50                flags: ARRAY_SYNTAX_SHORT (%d)
51                0: AST_ARRAY_ELEM
52                    flags: 0
53                    value: AST_VAR
54                        name: "i"
55                    key: null
56        returnType: AST_TYPE
57            flags: TYPE_ARRAY (%d)
58        __declId: 1
59    2: AST_ARROW_FUNC
60        name: "{closure}"
61        docComment: null
62        params: AST_PARAM_LIST
63            0: AST_PARAM
64                type: AST_NAME
65                    flags: NAME_NOT_FQ (%d)
66                    name: "stdClass"
67                name: "param"
68                default: null
69        stmts: AST_RETURN
70            expr: AST_VAR
71                name: "param"
72        returnType: AST_NAME
73            flags: NAME_FQ (%d)
74            name: "stdClass"
75        __declId: 2
76    3: AST_ARROW_FUNC
77        name: "{closure}"
78        docComment: null
79        params: AST_PARAM_LIST
80            0: AST_PARAM
81                type: AST_NAME
82                    flags: NAME_FQ (%d)
83                    name: "stdClass"
84                name: "param"
85                default: null
86        stmts: AST_RETURN
87            expr: AST_VAR
88                name: "param"
89        returnType: AST_NAME
90            flags: NAME_NOT_FQ (%d)
91            name: "stdClass"
92        __declId: 3
93
94Deprecated: ast\parse_code(): Version 50 is deprecated in %sshort_arrow_function_return.php on line 16
95Same representation in version 50/70: true