Every error reported by PHPStan is associated with an error identifier. The identifier is printed alongside each error in the analysis output:
Error identifiers are also visible when browsing errors with PHPStan Pro.
Error identifiers are also visible when browsing errors with PHPStan Pro.
Ignoring errors using identifiers #
Error identifiers can be used to ignore specific errors. Some errors are non-ignorable because they indicate code that would cause a crash or a fatal error at runtime.
You can ignore errors using inline comments in all PHP comment styles:
// @phpstan-ignore argument.type
$this->foo->doSomethingWithString(1);
You can also ignore errors in your configuration file using the identifier key:
parameters:
ignoreErrors:
-
identifier: argument.type
Or with the identifiers key to ignore multiple identifiers at once:
parameters:
ignoreErrors:
-
identifiers:
- argument.type
- argument.named
See the Ignoring Errors documentation for the full list of options.
Error identifier detail pages #
Each error identifier has its own detail page with information about why the error is reported, example code that triggers it, and examples of how to fix it.
All error identifier groups #
A
C
E
I
M
P
paramClosureThis.*
1
parameter.*
28
parameterByRef.*
4
paramImmediatelyInvokedCallable.*
1
paramLaterInvokedCallable.*
1
paramOut.*
4
phpDoc.*
2
phpParser.*
2
phpstan.*
16
phpstanApi.*
14
phpstanPlayground.*
🔧
7
phpunit.*
🔧
20
pipe.*
1
plus.*
2
possiblyImpure.*
5
postDec.*
6
postInc.*
6
pow.*
2
preDec.*
6
preInc.*
6
print.*
1
property.*
🔧
91
propertyGetHook.*
1
propertySetHook.*
3
propertyTag.*
8
pureFunction.*
5
pureMethod.*
5
purePropertyHook.*
5
S
These errors can be fixed automatically by running PHPStan with the --fix option.
argument.*
-
argument.named auto-fixableNamed argument used in a call that does not accept named arguments.
backtick.*
-
backtick.deprecated auto-fixableBacktick operator for shell execution is deprecated in PHP 8.5.
cast.*
-
Value is cast to the type it already has, making the cast redundant.
classConstant.*
-
classConstant.missingOverride auto-fixableClass constant overrides a parent or interface constant but is missing the #[Override] attribute.
-
Class constant has the #[Override] attribute but does not override any constant.
enum.*
-
enum.caseMissingOverride auto-fixableEnum case overrides an interface constant but is missing the #[Override] attribute.
-
Enum case has the #[Override] attribute but does not override any constant.
ignore.*
-
Ignoring all errors on a line is not allowed.
-
Ignored error count does not match the actual number of occurrences.
-
Ignored error pattern in configuration was not matched by any actual error.
-
Inline @phpstan-ignore specifies an identifier that is not reported on that line.
-
Ignore-line or ignore-next-line comment is on a line with no error.
method.*
-
method.missingOverride auto-fixableOverriding method is missing the #[Override] attribute.
-
Method has the #[Override] attribute but does not override any parent method.
phpstanPlayground.*
-
Playground suggests enabling a configuration parameter for additional checks.
phpunit.*
-
assertSame() with count() should be replaced with assertCount().
-
Calling PHPUnit's assertEmpty() or assertNotEmpty() is disallowed in favour of a more strict assertion.
-
assertEquals() with same-type scalars should use assertSame() instead.
-
assertSame(false, ...) should be replaced with assertFalse().
-
assertSame(null, ...) should be replaced with assertNull().
-
assertSame(true, ...) should be replaced with assertTrue().
-
RequiresPhp or RequiresPhpunit attribute has an invalid, incomplete, or unsatisfiable version requirement.
-
Overridden setUp() or tearDown() does not call the parent method.
-
Data provider method is not static, which is required by PHPUnit 10+.
property.*
-
property.missingOverride auto-fixableOverriding property is missing the #[Override] attribute.
-
Property has #[Override] but does not override any parent property.