xref: /PHP-7.3/ext/tokenizer/tests/bug76437.phpt (revision 9b02ee0b)
1--TEST--
2Bug #76437 (token_get_all with TOKEN_PARSE flag fails to recognise close tag)
3--SKIPIF--
4<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
5--FILE--
6<?php
7$tests = [
8    ['<?=$a?>', 0],
9    ['<?php echo 2; ?>', 6],
10    ["<?php echo 2; ?>\n", 6],
11];
12foreach ($tests as [$code, $index]) {
13    $open_tag1 = token_get_all($code)[$index];
14    $open_tag2 = token_get_all($code, TOKEN_PARSE)[$index];
15    var_dump($open_tag1);
16    var_dump($open_tag1 === $open_tag2);
17}
18?>
19--EXPECT--
20array(3) {
21  [0]=>
22  int(380)
23  [1]=>
24  string(3) "<?="
25  [2]=>
26  int(1)
27}
28bool(true)
29array(3) {
30  [0]=>
31  int(381)
32  [1]=>
33  string(2) "?>"
34  [2]=>
35  int(1)
36}
37bool(true)
38array(3) {
39  [0]=>
40  int(381)
41  [1]=>
42  string(3) "?>
43"
44  [2]=>
45  int(1)
46}
47bool(true)
48