Error when parsing constants.
talbergs opened this issue · 1 comments
talbergs commented
From PHP7 on you can even define a multidimensional Array as Constant:
<?php
MY_LIST[0];
Parsing this results in error:
> tree-sitter parse /tmp/a.php
(program [0, 0] - [3, 0]
(php_tag [0, 0] - [0, 5])
(ERROR [2, 0] - [2, 7]
(name [2, 0] - [2, 7]))
(expression_statement [2, 7] - [2, 11]
(array_creation_expression [2, 7] - [2, 10]
(array_element_initializer [2, 8] - [2, 9]
(integer [2, 8] - [2, 9])))))
/tmp/a.php 0 ms (ERROR [2, 0] - [2, 7])
More information https://www.php.net/manual/en/language.constants.syntax.php
Alan-Stewart commented
I just discovered this myself. I'm glad there's a fix. As a work-around, it was pointed out to me that constant arrays in classes are accepted:
class HTTTP { const MSG = [HP_OK => 'OK']; };
echo '@'.HTTTP::MSG[$code+100].'@ ';