xref: /php-ast/tests/class_types.phpt (revision 260678d4)
1--TEST--
2Different class types
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10class A {}
11abstract class B {}
12final class C {}
13trait D {}
14interface E {}
15new class {};
16PHP;
17
18echo ast_dump(ast\parse_code($code, $version=70));
19
20?>
21--EXPECTF--
22AST_STMT_LIST
23    0: AST_CLASS
24        name: "A"
25        docComment: null
26        extends: null
27        implements: null
28        stmts: AST_STMT_LIST
29        __declId: 0
30    1: AST_CLASS
31        flags: CLASS_ABSTRACT (%d)
32        name: "B"
33        docComment: null
34        extends: null
35        implements: null
36        stmts: AST_STMT_LIST
37        __declId: 1
38    2: AST_CLASS
39        flags: CLASS_FINAL (%d)
40        name: "C"
41        docComment: null
42        extends: null
43        implements: null
44        stmts: AST_STMT_LIST
45        __declId: 2
46    3: AST_CLASS
47        flags: CLASS_TRAIT (%d)
48        name: "D"
49        docComment: null
50        extends: null
51        implements: null
52        stmts: AST_STMT_LIST
53        __declId: 3
54    4: AST_CLASS
55        flags: CLASS_INTERFACE (%d)
56        name: "E"
57        docComment: null
58        extends: null
59        implements: null
60        stmts: AST_STMT_LIST
61        __declId: 4
62    5: AST_NEW
63        class: AST_CLASS
64            flags: CLASS_ANONYMOUS (%d)
65            name: null
66            docComment: null
67            extends: null
68            implements: null
69            stmts: AST_STMT_LIST
70            __declId: 5
71        args: AST_ARG_LIST
72