website/errors/ignore.allLineErrors.md
In phpstan.neon:
parameters:
reportIgnoresWithoutComments: true
<?php
// @phpstan-ignore-next-line
echo $undefined;
echo $anotherUndefined; // @phpstan-ignore-line
When reportIgnoresWithoutComments is enabled, PHPStan disallows @phpstan-ignore-next-line and @phpstan-ignore-line completely. These directives suppress all errors on a line without specifying which error identifiers are being ignored and without requiring an explanation.
This makes it too easy to accidentally suppress unrelated errors that appear on the same line in the future.
Replace the blanket ignore with @phpstan-ignore using a specific error identifier and a comment explaining why:
-// @phpstan-ignore-next-line
+// @phpstan-ignore variable.undefined (used for legacy compatibility)
echo $undefined;
-echo $anotherUndefined; // @phpstan-ignore-line
+echo $anotherUndefined; // @phpstan-ignore variable.undefined (loaded dynamically)
Each identifier must have an accompanying comment in parentheses. Learn more about ignoring errors in Ignoring Errors.