1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
--TEST--
Nullable types
--FILE--
<?php
require __DIR__ . '/../util.php';
$code = <<<'PHP'
<?php
function test(?Foo $foo) : ?Bar {
}
function test(?int $foo) : ?int {
}
function test(?array $foo) : ?array {
}
PHP;
echo ast_dump(ast\parse_code($code, $version=70));
?>
--EXPECT--
AST_STMT_LIST
0: AST_FUNC_DECL
name: "test"
docComment: null
params: AST_PARAM_LIST
0: AST_PARAM
type: AST_NULLABLE_TYPE
type: AST_NAME
flags: NAME_NOT_FQ (1)
name: "Foo"
name: "foo"
default: null
stmts: AST_STMT_LIST
returnType: AST_NULLABLE_TYPE
type: AST_NAME
flags: NAME_NOT_FQ (1)
name: "Bar"
__declId: 0
1: AST_FUNC_DECL
name: "test"
docComment: null
params: AST_PARAM_LIST
0: AST_PARAM
type: AST_NULLABLE_TYPE
type: AST_TYPE
flags: TYPE_LONG (4)
name: "foo"
default: null
stmts: AST_STMT_LIST
returnType: AST_NULLABLE_TYPE
type: AST_TYPE
flags: TYPE_LONG (4)
__declId: 1
2: AST_FUNC_DECL
name: "test"
docComment: null
params: AST_PARAM_LIST
0: AST_PARAM
type: AST_NULLABLE_TYPE
type: AST_TYPE
flags: TYPE_ARRAY (7)
name: "foo"
default: null
stmts: AST_STMT_LIST
returnType: AST_NULLABLE_TYPE
type: AST_TYPE
flags: TYPE_ARRAY (7)
__declId: 2
|