xref: /php-ast/tests/concat.phpt (revision 0f9c6809)
1--TEST--
2AST_CONCAT with/without parenthesis
3--FILE--
4<?php
5// PHP 7.4 changed the internal representation of concatenation operations.
6// This tests that php-ast consistently exposes the AST in PHP 7.0-7.4
7// For https://github.com/nikic/php-ast/issues/123
8require __DIR__ . '/../util.php';
9
10$code = <<<'PHP'
11<?php
12require_once __DIR__ . '/first.php';
13require_once(__DIR__ . '/second.php');
14PHP;
15
16echo ast_dump(ast\parse_code($code, $version=70)), "\n";
17
18?>
19--EXPECTF--
20AST_STMT_LIST
21    0: AST_INCLUDE_OR_EVAL
22        flags: EXEC_REQUIRE_ONCE (%d)
23        expr: AST_BINARY_OP
24            flags: BINARY_CONCAT (%d)
25            left: AST_MAGIC_CONST
26                flags: MAGIC_DIR (%d)
27            right: "/first.php"
28    1: AST_INCLUDE_OR_EVAL
29        flags: EXEC_REQUIRE_ONCE (%d)
30        expr: AST_BINARY_OP
31            flags: BINARY_CONCAT (%d)
32            left: AST_MAGIC_CONST
33                flags: MAGIC_DIR (%d)
34            right: "/second.php"
35