website/errors/ignore.noComment.md
In phpstan.neon:
parameters:
reportIgnoresWithoutComments: true
<?php
// @phpstan-ignore variable.undefined
echo $undefined;
When reportIgnoresWithoutComments is enabled, every @phpstan-ignore identifier must have an accompanying comment in parentheses explaining why the error is being ignored.
This ensures that ignored errors are documented and reviewable, making it clear to other developers (and your future self) why each suppression exists.
Add a comment in parentheses after the identifier:
-// @phpstan-ignore variable.undefined
+// @phpstan-ignore variable.undefined (not available at this point)
echo $undefined;
When ignoring multiple identifiers on the same line, each one needs its own comment:
-echo $foo; // @phpstan-ignore variable.undefined, wrong.id
+echo $foo; // @phpstan-ignore variable.undefined (reason), wrong.id (reason)
Learn more about ignoring errors in Ignoring Errors.