Skip to content

tree-sitter-php grammar.js does not support PHP 8.1+ language features #3

@bengibbs-pixieset

Description

@bengibbs-pixieset

I'm encountering warnings when running the GitLab SAST tool against my PHP repository. The output contains many readonly warning like this:

[WARN] [Semgrep] [2026-01-08T22:02:30Z] ▶ tool notification warning: Syntax error Syntax error at line src/app/DIR/FILENAME.php:22:
 `readonly` was unexpected

I found this Issue which outlines that the problem seems to be a lack of support for PHP 8.1+ language features. The comments in that issues led me to this semgrep/semgrep-php repository where I think I've spotted the bug.

Although the fyi/tree-sitter-version file says it is at v0.22.6, the fyi/semgrep-grammars/src/tree-sitter-php/grammar.js file does not seem to match the actual grammar.js file from the tree-sitter/tree-sitter-php repository at that version: https://github.com/tree-sitter/tree-sitter-php/blob/v0.22.6/common/define-grammar.js

The most obvious tell is that if you search for readonly in each grammar.js file you'll see:

I imagine that if the fyi/semgrep-grammars/src/tree-sitter-php/grammar.js file is updated to match the 0.22.6 version from the tree-sitter/tree-sitter-php repository then these unexpected readonly warnings will no longer appear.

I don't feel confident creating a Pull Request because I don't really understand what is happening in these grammar.js files, and I wouldn't know how to test it, sorry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions