Error Identifier: ignore.unmatchedIdentifier
Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
<?php declare(strict_types = 1);
function add(int $a, int $b): int
{
return $a + $b; // @phpstan-ignore return.type
}
Why is it reported? #
An @phpstan-ignore comment specifies an error identifier, but no error with that identifier is actually reported on the given line. This means the ignore directive is unnecessary – either the error was already fixed, the code was changed, or the identifier was specified incorrectly.
This error is reported when the reportUnmatchedIgnoredErrors parameter is enabled (which is the default).
How to fix it #
Remove the unnecessary ignore comment if the error no longer occurs:
<?php declare(strict_types = 1);
function add(int $a, int $b): int
{
- return $a + $b; // @phpstan-ignore return.type
+ return $a + $b;
}
If the error should still be ignored but the identifier is wrong, correct it to match the actual error identifier. You can find the correct identifier by temporarily removing the ignore comment and running PHPStan to see the reported error with its identifier.
How to ignore this error #
You can use the identifier ignore.unmatchedIdentifier to ignore this error using a comment:
// @phpstan-ignore ignore.unmatchedIdentifier
codeThatProducesTheError();
You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:
parameters:
ignoreErrors:
-
identifier: ignore.unmatchedIdentifier
Rules that report this error #
- PHPStan\Analyser\AnalyserResultFinalizer [1]