xref: /PHP-8.0/ext/tokenizer/tests/bug76991.phpt (revision ced5bb7d)
1--TEST--
2Bug #76991: Incorrect tokenization of multiple invalid flexible heredoc strings
3--SKIPIF--
4<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
5--FILE--
6<?php
7
8$code = <<<CODE
9<?php
10<<<TEST
11\$a
12 TEST;
13
14<<<END
15\$a
16 END;
17CODE;
18foreach (token_get_all($code) as $token) {
19    if (is_array($token)) {
20        echo token_name($token[0]) . ": " .str_replace("\n", '\n', $token[1]);
21    } else {
22        echo $token;
23    }
24    echo "\n";
25}
26
27?>
28--EXPECT--
29T_OPEN_TAG: <?php\n
30T_START_HEREDOC: <<<TEST\n
31T_VARIABLE: $a
32T_ENCAPSED_AND_WHITESPACE: \n
33T_END_HEREDOC:  TEST
34;
35T_WHITESPACE: \n\n
36T_START_HEREDOC: <<<END\n
37T_VARIABLE: $a
38T_ENCAPSED_AND_WHITESPACE: \n
39T_END_HEREDOC:  END
40;
41