Fixes vimeo/psalm#8374
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.
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
- ConfigIssue
- DuplicateArrayKey
- DuplicateClass
- DuplicateFunction
- DuplicateMethod
- DuplicateParam
- EmptyArrayAccess
- ExtensionRequirementViolation
- ImplementationRequirementViolation
- ImpureByReferenceAssignment
- ImpureFunctionCall
- ImpureMethodCall
- ImpurePropertyAssignment
- ImpurePropertyFetch
- ImpureStaticProperty
- ImpureStaticVariable
- ImpureVariable
- InaccessibleClassConstant
- InaccessibleMethod
- InaccessibleProperty
- InterfaceInstantiation
- InvalidAttribute
- InvalidEnumMethod
- InvalidExtendClass
- InvalidGlobal
- InvalidInterfaceImplementation
- InvalidParamDefault
- InvalidParent
- InvalidPassByReference
- InvalidScope
- InvalidStaticInvocation
- InvalidThrow
- LoopInvalidation
- MethodSignatureMustOmitReturnType
- MethodSignatureMustProvideReturnType
- 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 appear at level 7 and below
- AbstractInstantiation
- AssignmentToVoid
- CircularReference
- ConflictingReferenceConstraint
- ContinueOutsideLoop
- InvalidTypeImport
- MethodSignatureMismatch
- OverriddenMethodAccess
- ParamNameMismatch
- ReservedWord
- UnhandledMatchCondition
- UninitializedProperty
Errors that appear 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 that appear at level 5 and below
- ConstructorSignatureMismatch
- FalsableReturnStatement
- InvalidNullableReturnType
- LessSpecificImplementedReturnType
- MoreSpecificImplementedParamType
- NullableReturnStatement
- UndefinedInterfaceMethod
- UndefinedThisPropertyAssignment
Errors that appear at level 4 and below
- FalseOperand
- ForbiddenCode
- ImplementedParamTypeMismatch
- ImplementedReturnTypeMismatch
- ImplicitToStringCast
- InternalClass
- InternalMethod
- InternalProperty
- InvalidDocblock
- InvalidLiteralArgument
- InvalidOperand
- InvalidScalarArgument
- InvalidToString
- MismatchingDocblockParamType
- MismatchingDocblockReturnType
- MissingDocblockType
- NoInterfaceProperties
- PossibleRawObjectIteration
- RedundantCondition
- RedundantFunctionCall
- RedundantPropertyInitializationCheck
- StringIncrement
- TooManyArguments
- TypeDoesNotContainNull
- TypeDoesNotContainType
- UndefinedMagicMethod
- UndefinedMagicPropertyAssignment
- UndefinedMagicPropertyFetch
Errors that appear 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
- RiskyCast
Errors that appear at level 2 and below
- DeprecatedClass
- DeprecatedConstant
- DeprecatedFunction
- DeprecatedInterface
- DeprecatedMethod
- DeprecatedProperty
- DeprecatedTrait
- DirectConstructorCall
- DocblockTypeContradiction
- InvalidDocblockParamName
- InvalidFalsableReturnType
- InvalidStringClass
- MissingClosureParamType
- MissingClosureReturnType
- MissingConstructor
- MissingParamType
- MissingPropertyType
- MissingReturnType
- NullOperand
- PrivateFinalMethod
- PropertyNotSetInConstructor
- RawObjectIteration
- RedundantConditionGivenDocblockType
- RedundantFunctionCallGivenDocblockType
- ReferenceConstraintViolation
- UndefinedTrace
- UnresolvableInclude
- UnsafeInstantiation
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
Feature-specific errors
- 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
- UnusedDocblockParam
- UnusedForeachValue
- UnusedMethod
- UnusedParam
- UnusedProperty
- UnusedPsalmSuppress
- UnusedVariable