Ignore comments
Suppress specific rules for a line, region, or file.
An ignore comment turns off named rules for a line, a region, or a file. It names full rule IDs, such as lint/security/no-eval, or groups, such as lint/dead-code. Separate several IDs with commas.
| Form | Applies to |
|---|---|
$x = foo(); // @pun-ignore analyse/undefined/function |
The line it ends |
// @pun-ignore lint/types/no-loose-comparison on its own line |
The next line |
// @pun-ignore-next-line <id> |
The next line |
// @pun-ignore-file <id> before the first statement |
The whole file |
// @pun-ignore-start <id> … // @pun-ignore-end |
A region |
To record why, add a reason after --:
eval($code); // @pun-ignore lint/security/no-eval -- legacy plugin loader
Scope and validation
/* */and/** */comments work too.- Format rules, and the lint rules that come from PHP-CS-Fixer, accept only
@pun-ignore-file. - An ignore comment without an ID is an error.
- Non-ignorable analyse errors stay visible. Their rule pages say so.
lint/comments/no-unused-ignorereports IDs that suppress nothing.--fixremoves them.
pun migrate converts the PHPStan and PHP-CS-Fixer ignore comments it recognizes.