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 Xyz { 13 public function test() : static { 14 return $this; 15 } 16 public function test2() : static|false|OtherClass { 17 return $this; 18 } 19} 20PHP; 21 22$node = ast\parse_code($code, $version=70); 23echo ast_dump($node), "\n"; 24--EXPECTF-- 25AST_STMT_LIST 26 0: AST_CLASS 27 name: "Xyz" 28 docComment: null 29 extends: null 30 implements: null 31 stmts: AST_STMT_LIST 32 0: AST_METHOD 33 flags: MODIFIER_PUBLIC (%d) 34 name: "test" 35 docComment: null 36 params: AST_PARAM_LIST 37 stmts: AST_STMT_LIST 38 0: AST_RETURN 39 expr: AST_VAR 40 name: "this" 41 returnType: AST_TYPE 42 flags: TYPE_STATIC (%d) 43 __declId: 0 44 1: AST_METHOD 45 flags: MODIFIER_PUBLIC (%d) 46 name: "test2" 47 docComment: null 48 params: AST_PARAM_LIST 49 stmts: AST_STMT_LIST 50 0: AST_RETURN 51 expr: AST_VAR 52 name: "this" 53 returnType: AST_TYPE_UNION 54 0: AST_TYPE 55 flags: TYPE_STATIC (%d) 56 1: AST_TYPE 57 flags: TYPE_FALSE (%d) 58 2: AST_NAME 59 flags: NAME_NOT_FQ (%d) 60 name: "OtherClass" 61 __declId: 1 62 __declId: 2