NoVerify uses Dynamic Rules to perform PHP code inspections. A Rule consists of a PHPDoc comment containing inspection metadata and a phpgrep pattern that defines the syntax to match.
A Rule file is a valid PHP file containing a sequence of PHP functions or statements. Each function or statement is interpreted as a phpgrep pattern, and the PHPDoc comments provide the necessary metadata to turn those patterns into actionable inspections.
Because rule files are valid PHP, you can use IDEs like PhpStorm to work with them. To use them in NoVerify, pass the file or directory to the --rules command-line argument.
Key Terminology:
- Rule: A pattern + PHPDoc metadata.
- Rule file: A collection of rules (PHP functions/statements).
- Rule group: A PHP function that acts as a container for multiple rules. The function name becomes the check name.
# Run analysis with a specific rule file
noverify --rules path/to/rules.php
# Run analysis with a folder of rule files (non-recursive)
noverify --rules path/to/rules_folder/