Error Identifiers
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.
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.
Examples:
All error identifier groups #
- argument.* (26 identifiers)
- arguments.* (1 identifier)
- array.* (2 identifiers)
- arrayFilter.* (4 identifiers)
- arrayUnpacking.* (2 identifiers)
- arrayValues.* (2 identifiers)
- assert.* (11 identifiers)
- assign.* (11 identifiers)
- assignOp.* (1 identifier)
- attribute.* (13 identifiers)
- backtick.* (2 identifiers)
- binaryOp.* (1 identifier)
- booleanAnd.* (9 identifiers)
- booleanNot.* (3 identifiers)
- booleanOr.* (9 identifiers)
- break.* (1 identifier)
- callable.* (8 identifiers)
- cast.* (8 identifiers)
- catch.* (8 identifiers)
- class.* (28 identifiers)
- classConstant.* (35 identifiers)
- classImplements.* (3 identifiers)
- clone.* (1 identifier)
- closure.* (4 identifiers)
- conditionalType.* (3 identifiers)
- consistentConstructor.* (1 identifier)
- constant.* (4 identifiers)
- constructor.* (4 identifiers)
- continue.* (1 identifier)
- deadCode.* (1 identifier)
- declareStrictTypes.* (2 identifiers)
- div.* (2 identifiers)
- doctrine.* (14 identifiers)
- doWhile.* (3 identifiers)
- echo.* (1 identifier)
- elseif.* (3 identifiers)
- empty.* (6 identifiers)
- encapsedStringPart.* (1 identifier)
- enum.* (24 identifiers)
- enumImplements.* (3 identifiers)
- equal.* (4 identifiers)
- expr.* (1 identifier)
- filterVar.* (1 identifier)
- finally.* (1 identifier)
- for.* (1 identifier)
- foreach.* (4 identifiers)
- function.* (16 identifiers)
- generator.* (7 identifiers)
- generics.* (36 identifiers)
- global.* (1 identifier)
- greater.* (3 identifiers)
- greaterOrEqual.* (3 identifiers)
- identical.* (2 identifiers)
- if.* (3 identifiers)
- ignore.* (7 identifiers)
- impure.* (19 identifiers)
- impureFunction.* (1 identifier)
- impureMethod.* (1 identifier)
- include.* (1 identifier)
- includeOnce.* (1 identifier)
- instanceof.* (12 identifiers)
- interface.* (13 identifiers)
- interfaceExtends.* (3 identifiers)
- isset.* (5 identifiers)
- logicalAnd.* (9 identifiers)
- logicalOr.* (9 identifiers)
- logicalXor.* (5 identifiers)
- magicConstant.* (4 identifiers)
- match.* (4 identifiers)
- method.* (43 identifiers)
- methodTag.* (9 identifiers)
- minus.* (2 identifiers)
- missingType.* (7 identifiers)
- mixin.* (9 identifiers)
- mod.* (2 identifiers)
- mul.* (2 identifiers)
- nette.* (1 identifier)
- new.* (14 identifiers)
- notEqual.* (4 identifiers)
- notIdentical.* (2 identifiers)
- nullableType.* (3 identifiers)
- nullCoalesce.* (5 identifiers)
- nullsafe.* (3 identifiers)
- offsetAccess.* (5 identifiers)
- offsetAssign.* (2 identifiers)
- outOfClass.* (3 identifiers)
- paramClosureThis.* (1 identifier)
- parameter.* (29 identifiers)
- parameterByRef.* (4 identifiers)
- paramImmediatelyInvokedCallable.* (1 identifier)
- paramLaterInvokedCallable.* (1 identifier)
- paramOut.* (4 identifiers)
- phpDoc.* (2 identifiers)
- phpParser.* (2 identifiers)
- phpstan.* (16 identifiers)
- phpstanApi.* (13 identifiers)
- phpstanPlayground.* (8 identifiers)
- phpunit.* (18 identifiers)
- pipe.* (1 identifier)
- plus.* (2 identifiers)
- possiblyImpure.* (4 identifiers)
- postDec.* (3 identifiers)
- postInc.* (3 identifiers)
- pow.* (2 identifiers)
- preDec.* (3 identifiers)
- preInc.* (3 identifiers)
- print.* (1 identifier)
- property.* (88 identifiers)
- propertyGetHook.* (1 identifier)
- propertySetHook.* (3 identifiers)
- propertyTag.* (8 identifiers)
- pureFunction.* (2 identifiers)
- pureMethod.* (2 identifiers)
- regexp.* (1 identifier)
- require.* (1 identifier)
- requireExtends.* (10 identifiers)
- requireImplements.* (9 identifiers)
- requireOnce.* (1 identifier)
- return.* (23 identifiers)
- sealed.* (11 identifiers)
- selfOut.* (11 identifiers)
- smaller.* (3 identifiers)
- smallerOrEqual.* (3 identifiers)
- spaceship.* (1 identifier)
- static.* (1 identifier)
- staticClassAccess.* (3 identifiers)
- staticMethod.* (25 identifiers)
- staticProperty.* (16 identifiers)
- switch.* (1 identifier)
- symfonyConsole.* (2 identifiers)
- symfonyContainer.* (2 identifiers)
- ternary.* (5 identifiers)
- throw.* (2 identifiers)
- throws.* (6 identifiers)
- trait.* (9 identifiers)
- traitUse.* (5 identifiers)
- typeAlias.* (13 identifiers)
- unaryMinus.* (1 identifier)
- unaryOp.* (1 identifier)
- unaryPlus.* (1 identifier)
- unionType.* (3 identifiers)
- unset.* (6 identifiers)
- use.* (1 identifier)
- variable.* (3 identifiers)
- varTag.* (17 identifiers)
- void.* (1 identifier)
- while.* (3 identifiers)
- whitespace.* (2 identifiers)