VKCOM / noverify

Pretty fast linter (code static analysis utility) for PHP
MIT License
673 stars 57 forks source link

Fix @filter behavior in phpgrep rules #1200

Open quasilyte opened 2 years ago

quasilyte commented 2 years ago

dynamic rules @filter should work like phpgrep CLI filters.

What should be changed:

  1. There should be no restrictions on the variable expression. ${"x:const"} should work as well as $x; the :const part specifies the node class
  2. When matching, $x with a filter should not be limited to variables; $x matches anything in phpgrep. Instead of matching by variable name after a type assertion, a text slice should be taken using the $x node position info (it has begin+end positions). We usually have the current file source available during the analysis as []byte.