1--TEST--
2Union types in PHP 8.0
3--SKIPIF--
4<?php if (PHP_VERSION_ID < 80000) die('skip PHP >= 8.0 only'); ?>
5--FILE--
6<?php
7
8require __DIR__ . '/../util.php';
9
10$code = <<<'PHP'
11<?php
12class Example {
13    public iterable|null|false $value;
14}
15// These are semantic errors, not syntax errors
16$f = fn(OBJECT|false $a) : false => $a;
17$g = function (false $arg) : false|null { return false; };
18PHP;
19
20$node = ast\parse_code($code, $version=70);
21echo ast_dump($node), "\n";
22--EXPECTF--
23AST_STMT_LIST
24    0: AST_CLASS
25        name: "Example"
26        docComment: null
27        extends: null
28        implements: null
29        stmts: AST_STMT_LIST
30            0: AST_PROP_GROUP
31                flags: MODIFIER_PUBLIC (%d)
32                type: AST_TYPE_UNION
33                    0: AST_TYPE
34                        flags: TYPE_ITERABLE (%d)
35                    1: AST_TYPE
36                        flags: TYPE_NULL (%d)
37                    2: AST_TYPE
38                        flags: TYPE_FALSE (%d)
39                props: AST_PROP_DECL
40                    0: AST_PROP_ELEM
41                        name: "value"
42                        default: null
43                        docComment: null
44        __declId: 0
45    1: AST_ASSIGN
46        var: AST_VAR
47            name: "f"
48        expr: AST_ARROW_FUNC
49            name: "{closure}"
50            docComment: null
51            params: AST_PARAM_LIST
52                0: AST_PARAM
53                    type: AST_TYPE_UNION
54                        0: AST_TYPE
55                            flags: TYPE_OBJECT (%d)
56                        1: AST_TYPE
57                            flags: TYPE_FALSE (%d)
58                    name: "a"
59                    default: null
60            stmts: AST_RETURN
61                expr: AST_VAR
62                    name: "a"
63            returnType: AST_TYPE
64                flags: TYPE_FALSE (%d)
65            __declId: 1
66    2: AST_ASSIGN
67        var: AST_VAR
68            name: "g"
69        expr: AST_CLOSURE
70            name: "{closure}"
71            docComment: null
72            params: AST_PARAM_LIST
73                0: AST_PARAM
74                    type: AST_TYPE
75                        flags: TYPE_FALSE (%d)
76                    name: "arg"
77                    default: null
78            uses: null
79            stmts: AST_STMT_LIST
80                0: AST_RETURN
81                    expr: AST_CONST
82                        name: AST_NAME
83                            flags: NAME_NOT_FQ (%d)
84                            name: "false"
85            returnType: AST_TYPE_UNION
86                0: AST_TYPE
87                    flags: TYPE_FALSE (%d)
88                1: AST_TYPE
89                    flags: TYPE_NULL (%d)
90            __declId: 2
91