Skip to content

chore: update to tree-sitter-php v0.24#46

Draft
claytonrcarter wants to merge 1 commit intomasterfrom
update-tree-sitter-php-0.24
Draft

chore: update to tree-sitter-php v0.24#46
claytonrcarter wants to merge 1 commit intomasterfrom
update-tree-sitter-php-0.24

Conversation

@claytonrcarter
Copy link
Owner

I'm parking this here for now, perhaps others can take a peek and offer suggestions.

Updating to tree-sitter-php v0.24 also needs an update to tree-sitter v0.25, because the PHP grammar is making use of the reserved() API that was introduced in that version. I've been able to pull in the reserved settings from the PHP grammar and (I think) wire them up, but I'm stuck with a error:

❯ ./node_modules/.bin/tree-sitter generate
Error when generating parser

Caused by:
    Reserved word 'abstract' must be a token

This error seems to be coming from https://github.com/tree-sitter/tree-sitter/blob/eacb95c85da15005f091729f3225609d0db67963/crates/generate/src/prepare_grammar/extract_tokens.rs#L225, but I suspect that we are just missing some other grammar config, because even just copying the PHP reserved words into this grammar as static strings (vs trying to import/rebuild, as in this PR) results in this error. And changing the value of the first entry in the classes reserved set will just give the same error, but w/ the updated value:

reserved: {
    classes: (_) => ['foobar'],
  },

...

Error when generating parser

Caused by:
    Reserved word 'foobar' must be a token

So I suspect that I'm just missing something about this new API and how it works, or some other change that happened when the PHP grammar adopted the new API in tree-sitter/tree-sitter-php@33d7002

Suggestions and input are welcome!

@solstag
Copy link

solstag commented Jan 8, 2026

Not sure if this may help, but I get a slightly different output with ts-phpdoc:master and ts-php:0.24.0 (also 0.24.2):

Warning: No `tree-sitter.json` file found in your grammar, this file is required to generate with ABI 15. Using ABI version 14 instead.
This file can be set up with `tree-sitter init`. For more information, see https://tree-sitter.github.io/tree-sitter/cli/init.

Warning: rule _psalm_tag contains a `seq` or `choice` rule with a single element. This is unnecessary.

Error when generating parser

Caused by:
    No such reserved word set: classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants