Based on crates.io tree-sitter-php 0.24.2, upstream
https://github.com/tree-sitter/tree-sitter-php. Original MIT LICENSE is retained.
grammar.patch records all changes from that release.
Changes in common/define-grammar.js:
exit_statementaccepts an optional expression (including parenthesized expressions), as well as emptyexit(). The original rule accepted only parentheses, rejecting validexit -1;andexit -callee();._simple_string_member_access_expressionusesreserved('nothing', $.name)for property names. This accepts keyword properties such as"$item->class"without swallowing the following escape or interpolated variable.- A distinct
short_echo_statementrepresents<?=and its comma-separated expression list, both at the beginning of a file and in mixed HTML/PHP. Ordinary expression statements still accept only a single expression. - Class constant elements accept
TRUE/FALSEas names, despite their lexical classification as Boolean literals in other expression contexts. - A promoted parameter can start with
readonlywithout an explicit visibility modifier. It must still have either visibility or readonly. - Grouped namespace imports accept a trailing comma, including mixed and function groups.
- Cast expressions accept a match expression as their operand.
No ignored ERROR nodes or relaxed general error handling. PHP identifier byte
encoding is handled separately in src/php.rs: invalid UTF-8 bytes become
U+F100 followed by U+E000 + byte, while a literal U+F100 is doubled. The encoding
is injective, preserves normal UTF-8 and line numbers, and is also used for
Composer keys. Non-UTF-8 symbols have their encoded spellings in graph labels;
byte offsets used in entity IDs refer to the encoded source. Include path string
literals, literal HTML spans, and generated Composer path literals are decoded
back to their original spelling. DIR/FILE remain raw filesystem paths;
non-UTF-8 filesystem paths are not converted into invented Unicode paths.
Both variants' generated parser.c, grammar.json and node-types.json are shipped so building the extractor requires neither Node nor the generator.
Regenerate using tree-sitter-cli 0.25.10 (Node available on PATH):
(cd php && tree-sitter generate)
(cd php_only && tree-sitter generate)Extractor regressions are in tests/extraction.rs and
tests/parser_regressions.rs. The vendor-study PHP lint audit confirmed all
repaired corpus PHP files are valid PHP 8.3.12; the separate <?hh fixtures are
inventoried transparently as unsupported Hack, without PHP symbol extraction.