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