-
Notifications
You must be signed in to change notification settings - Fork 3
Description
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:
- 0 results in https://github.com/semgrep/semgrep-php/blob/main/fyi/semgrep-grammars/src/tree-sitter-php/grammar.js
- 5 results in https://github.com/tree-sitter/tree-sitter-php/blob/v0.22.6/common/define-grammar.js
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.