xref: /php-ast/tests/magic_constants.phpt (revision 91f59467)
1--TEST--
2Magic constants
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10__LINE__;
11__FILE__;
12__DIR__;
13__NAMESPACE__;
14__FUNCTION__;
15__METHOD__;
16__CLASS__;
17__TRAIT__;
18PHP;
19
20echo ast_dump(ast\parse_code($code, $version=70));
21
22?>
23--EXPECTF--
24AST_STMT_LIST
25    0: AST_MAGIC_CONST
26        flags: MAGIC_LINE (%d)
27    1: AST_MAGIC_CONST
28        flags: MAGIC_FILE (%d)
29    2: AST_MAGIC_CONST
30        flags: MAGIC_DIR (%d)
31    3: AST_MAGIC_CONST
32        flags: MAGIC_NAMESPACE (%d)
33    4: AST_MAGIC_CONST
34        flags: MAGIC_FUNCTION (%d)
35    5: AST_MAGIC_CONST
36        flags: MAGIC_METHOD (%d)
37    6: AST_MAGIC_CONST
38        flags: MAGIC_CLASS (%d)
39    7: AST_MAGIC_CONST
40        flags: MAGIC_TRAIT (%d)
41