* docs: mention default level * Update error_levels.md
16 KiB
Error levels
You can run Psalm in at different levels of strictness from 1 to 8.
Level 1 is the most strict, level 8 is the most lenient.
When no level is explicitly defined, psalm defaults to level 2.
In case totallyTyped
is enabled, psalm defaults to level 1.
Some issues are always treated as errors. These are issues with a very low probability of false-positives.
At level 1 all issues (except those emitted for opt-in features) that Psalm can find are treated as errors. Those issues include any situation where Psalm cannot infer the type of a given expression.
At level 2 Psalm ignores those Mixed*
issues, but treats most other issues as errors.
At level 3 Psalm starts to be a little more lenient. For example Psalm allows missing param types, return types and property types.
At level 4 Psalm ignores issues for possible problems. These are more likely to be false positives – where the application code may guarantee behaviour that Psalm isn't able to infer.
Level 5 and above allows a more non-verifiable code, and higher levels are even more permissive.
Always treated as errors
- AbstractMethodCall
- ComplexFunction
- ComplexMethod
- DuplicateArrayKey
- DuplicateClass
- DuplicateFunction
- DuplicateMethod
- DuplicateParam
- EmptyArrayAccess
- ExtensionRequirementViolation
- ImplementationRequirementViolation
- ImpureByReferenceAssignment
- ImpureFunctionCall
- ImpureMethodCall
- ImpurePropertyAssignment
- ImpurePropertyFetch
- ImpureStaticProperty
- ImpureStaticVariable
- ImpureVariable
- InaccessibleClassConstant
- InaccessibleMethod
- InaccessibleProperty
- InterfaceInstantiation
- InvalidAttribute
- InvalidExtendClass
- InvalidGlobal
- InvalidParamDefault
- InvalidParent
- InvalidPassByReference
- InvalidScope
- InvalidStaticInvocation
- InvalidThrow
- LoopInvalidation
- MethodSignatureMustOmitReturnType
- MissingDependency
- MissingFile
- MissingImmutableAnnotation
- MissingTemplateParam
- MissingThrowsDocblock
- NonStaticSelfCall
- NoValue
- NullArrayAccess
- NullFunctionCall
- NullIterator
- NullPropertyAssignment
- NullPropertyFetch
- NullReference
- OverriddenPropertyAccess
- ParadoxicalCondition
- ParentNotFound
- TooFewArguments
- UndefinedAttributeClass
- UndefinedClass
- UndefinedConstant
- UndefinedDocblockClass
- UndefinedFunction
- UndefinedGlobalVariable
- UndefinedInterface
- UndefinedTrait
- UndefinedVariable
- UnimplementedAbstractMethod
- UnimplementedInterfaceMethod
- UnrecognizedExpression
- UnrecognizedStatement
- UnusedFunctionCall
- UnusedMethodCall
Errors that only appear at level 1
- LessSpecificReturnType
- MixedArgument
- MixedArgumentTypeCoercion
- MixedArrayAccess
- MixedArrayAssignment
- MixedArrayOffset
- MixedArrayTypeCoercion
- MixedAssignment
- MixedClone
- MixedFunctionCall
- MixedInferredReturnType
- MixedMethodCall
- MixedOperand
- MixedPropertyAssignment
- MixedPropertyFetch
- MixedPropertyTypeCoercion
- MixedReturnStatement
- MixedReturnTypeCoercion
- MixedStringOffsetAssignment
- MutableDependency
- PossiblyNullOperand
- RedundantIdentityWithTrue
- Trace
Errors ignored at level 3 and higher
These issues are treated as errors at level 2 and below.
- DeprecatedClass
- DeprecatedConstant
- DeprecatedFunction
- DeprecatedInterface
- DeprecatedMethod
- DeprecatedProperty
- DeprecatedTrait
- DocblockTypeContradiction
- InvalidDocblockParamName
- InvalidFalsableReturnType
- InvalidStringClass
- MissingClosureParamType
- MissingClosureReturnType
- MissingConstructor
- MissingParamType
- MissingPropertyType
- MissingReturnType
- NullOperand
- PropertyNotSetInConstructor
- RawObjectIteration
- RedundantConditionGivenDocblockType
- ReferenceConstraintViolation
- UndefinedTrace
- UnresolvableInclude
- UnsafeInstantiation
Errors ignored at level 4 and higher
These issues are treated as errors at level 3 and below.
- ArgumentTypeCoercion
- LessSpecificReturnStatement
- MoreSpecificReturnType
- PossiblyFalseArgument
- PossiblyFalseIterator
- PossiblyFalseOperand
- PossiblyFalsePropertyAssignmentValue
- PossiblyFalseReference
- PossiblyInvalidArgument
- PossiblyInvalidArrayAccess
- PossiblyInvalidArrayAssignment
- PossiblyInvalidArrayOffset
- PossiblyInvalidCast
- PossiblyInvalidClone
- PossiblyInvalidFunctionCall
- PossiblyInvalidIterator
- PossiblyInvalidMethodCall
- PossiblyInvalidOperand
- PossiblyInvalidPropertyAssignment
- PossiblyInvalidPropertyAssignmentValue
- PossiblyInvalidPropertyFetch
- PossiblyNullArgument
- PossiblyNullArrayAccess
- PossiblyNullArrayAssignment
- PossiblyNullArrayOffset
- PossiblyNullFunctionCall
- PossiblyNullIterator
- PossiblyNullPropertyAssignment
- PossiblyNullPropertyAssignmentValue
- PossiblyNullPropertyFetch
- PossiblyNullReference
- PossiblyUndefinedArrayOffset
- PossiblyUndefinedGlobalVariable
- PossiblyUndefinedMethod
- PossiblyUndefinedVariable
- PropertyTypeCoercion
Errors ignored at level 5 and higher
These issues are treated as errors at level 4 and below.
- FalseOperand
- ForbiddenCode
- ImplementedParamTypeMismatch
- ImplementedReturnTypeMismatch
- ImplicitToStringCast
- InternalClass
- InternalMethod
- InternalProperty
- InvalidDocblock
- InvalidLiteralArgument
- InvalidOperand
- InvalidScalarArgument
- InvalidToString
- MismatchingDocblockParamType
- MismatchingDocblockReturnType
- MissingDocblockType
- NoInterfaceProperties
- PossibleRawObjectIteration
- RedundantCondition
- RedundantPropertyInitializationCheck
- StringIncrement
- TooManyArguments
- TypeDoesNotContainNull
- TypeDoesNotContainType
- UndefinedMagicMethod
- UndefinedMagicPropertyAssignment
- UndefinedMagicPropertyFetch
Errors ignored at level 6 and higher
These issues are treated as errors at level 5 and below.
- ConstructorSignatureMismatch
- FalsableReturnStatement
- InvalidNullableReturnType
- LessSpecificImplementedReturnType
- MoreSpecificImplementedParamType
- NullableReturnStatement
- UndefinedInterfaceMethod
- UndefinedThisPropertyAssignment
Errors ignored at level 7 and higher
These issues are treated as errors at level 6 and below.
- InvalidArgument
- InvalidArrayAccess
- InvalidArrayAssignment
- InvalidArrayOffset
- InvalidCast
- InvalidCatch
- InvalidClass
- InvalidClone
- InvalidFunctionCall
- InvalidIterator
- InvalidMethodCall
- InvalidNamedArgument
- InvalidPropertyAssignment
- InvalidPropertyAssignmentValue
- InvalidPropertyFetch
- InvalidReturnStatement
- InvalidReturnType
- InvalidTemplateParam
- NullArgument
- NullArrayOffset
- TooManyTemplateParams
- TraitMethodSignatureMismatch
- UndefinedMethod
- UndefinedPropertyAssignment
- UndefinedPropertyFetch
- UndefinedThisPropertyFetch
Errors ignored at level 8
These issues are treated as errors at level 7 and below.
- AbstractInstantiation
- AssignmentToVoid
- CircularReference
- ConflictingReferenceConstraint
- ContinueOutsideLoop
- InvalidTypeImport
- MethodSignatureMismatch
- OverriddenMethodAccess
- ParamNameMismatch
- ReservedWord
- UnhandledMatchCondition
- UninitializedProperty
Feature-specific errors
- ForbiddenEcho
- PossiblyUndefinedIntArrayOffset
- PossiblyUndefinedStringArrayOffset
- PossiblyUnusedMethod
- PossiblyUnusedParam
- PossiblyUnusedProperty
- TaintedCallable
- TaintedCookie
- TaintedCustom
- TaintedEval
- TaintedFile
- TaintedHeader
- TaintedHtml
- TaintedInclude
- TaintedInput
- TaintedLdap
- TaintedShell
- TaintedSql
- TaintedSSRF
- TaintedSystemSecret
- TaintedUnserialize
- TaintedUserSecret
- UncaughtThrowInGlobalScope
- UnevaluatedCode
- UnnecessaryVarAnnotation
- UnusedClass
- UnusedClosureParam
- UnusedConstructor
- UnusedMethod
- UnusedParam
- UnusedProperty
- UnusedPsalmSuppress
- UnusedVariable