-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy path001.phpt
70 lines (66 loc) · 2.1 KB
/
001.phpt
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
70
--TEST--
ast_dump() test
--SKIPIF--
<?php if (!extension_loaded("ast")) print "skip"; ?>
--FILE--
<?php
require __DIR__ . '/../util.php';
$code = <<<'PHP'
<?php
/** Test function */
function test(Type $arg = XYZ) : Ret {
if ($arg instanceof Foo\Bar) {
return test($arg->foo);
} else {
return $arg->bar;
}
}
PHP;
echo ast_dump(ast\parse_code($code, $version=70));
--EXPECT--
AST_STMT_LIST
0: AST_FUNC_DECL
name: "test"
docComment: "/** Test function */"
params: AST_PARAM_LIST
0: AST_PARAM
type: AST_NAME
flags: NAME_NOT_FQ (1)
name: "Type"
name: "arg"
default: AST_CONST
name: AST_NAME
flags: NAME_NOT_FQ (1)
name: "XYZ"
stmts: AST_STMT_LIST
0: AST_IF
0: AST_IF_ELEM
cond: AST_INSTANCEOF
expr: AST_VAR
name: "arg"
class: AST_NAME
flags: NAME_NOT_FQ (1)
name: "Foo\Bar"
stmts: AST_STMT_LIST
0: AST_RETURN
expr: AST_CALL
expr: AST_NAME
flags: NAME_NOT_FQ (1)
name: "test"
args: AST_ARG_LIST
0: AST_PROP
expr: AST_VAR
name: "arg"
prop: "foo"
1: AST_IF_ELEM
cond: null
stmts: AST_STMT_LIST
0: AST_RETURN
expr: AST_PROP
expr: AST_VAR
name: "arg"
prop: "bar"
returnType: AST_NAME
flags: NAME_NOT_FQ (1)
name: "Ret"
__declId: 0