Error Identifier: phpDoc.phpstanTag
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);
class Foo
{
/**
* @phpstan-pararm string $name
*/
public function setName(string $name): void
{
}
}
Why is it reported? #
The PHPDoc comment contains a tag starting with @phpstan- that is not recognized by PHPStan. This is most likely a typo in the tag name. In the example above, @phpstan-pararm should be @phpstan-param.
How to fix it #
Correct the tag name to a valid @phpstan- tag:
<?php declare(strict_types = 1);
class Foo
{
/**
- * @phpstan-pararm string $name
+ * @phpstan-param string $name
*/
public function setName(string $name): void
{
}
}
Common valid @phpstan- tags include @phpstan-param, @phpstan-return, @phpstan-var, @phpstan-template, @phpstan-extends, @phpstan-implements, @phpstan-type, @phpstan-import-type, @phpstan-assert, @phpstan-pure, @phpstan-impure, @phpstan-ignore, and others.
How to ignore this error #
You can use the identifier phpDoc.phpstanTag to ignore this error using a comment:
// @phpstan-ignore phpDoc.phpstanTag
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: phpDoc.phpstanTag
Rules that report this error #
- PHPStan\Rules\PhpDoc\InvalidPHPStanDocTagRule [1]