Issues
Each issue has a stable MIR#### code that appears in CLI, JSON and SARIF
output. Codes are never reused, so they’re safe to reference in suppressions,
baselines and CI filters. Error codes lists them in numeric order.
Every issue page shows an example and how to fix it. Some issues need to be turned on:
- Unused classes, functions, methods, properties and constants:
--find-dead-code. - Unused variables and foreach values:
--find-dead-codeor<findUnusedVariables>. - Info-level issues, mostly redundancies:
--show-info.
mir reports 203 kinds of issues.
Undefined
| Code | Issue | Description |
|---|---|---|
MIR0001 | InvalidScope | $this used outside a class or inside a static method. |
MIR0002 | UndefinedVariable | A variable is used before it has been assigned. |
MIR0003 | UndefinedFunction | A call targets a function that does not exist in the codebase or stubs. |
MIR0004 | UndefinedMethod | A method is called on a type that does not declare that method. |
MIR0005 | UndefinedClass | A reference is made to a class or interface that does not exist. |
MIR0006 | UndefinedProperty | A property is accessed that is not declared on the class. |
MIR0007 | UndefinedConstant | A reference is made to a constant that has not been defined. |
MIR0008 | PossiblyUndefinedVariable | A variable is only assigned in some branches and may be unset on other paths. |
MIR0009 | UndefinedTrait | A trait is used that does not exist in the codebase or stubs. |
MIR0010 | ParentNotFound | Use of parent:: in a class that has no parent. |
MIR0011 | InaccessibleClassConstant | Access to a private or protected class constant from an incompatible scope. |
MIR0012 | TraitConstantAccessedDirectly | A trait constant is accessed directly, which is not allowed in PHP. |
MIR0013 | UndefinedTraitAliasMethod | A method from a trait alias is used but the alias was not properly defined. |
MIR0014 | InaccessibleProperty | Access to a private or protected property from an incompatible scope. |
MIR0015 | PossiblyUndefinedMethod | A method is called on a union where only some members declare it. |
MIR0016 | InvalidDynamicProperty | A write creates an undeclared property on an enum or readonly class, which throws. |
Nullability
| Code | Issue | Description |
|---|---|---|
MIR0100 | NullArgument | null is passed to a parameter that does not accept null. |
MIR0101 | NullPropertyFetch | A property is accessed on a value that is possibly null. |
MIR0102 | NullMethodCall | A method is called on a value that is possibly null. |
MIR0103 | NullArrayAccess | Array access is performed on a value that is possibly null. |
MIR0104 | PossiblyNullArgument | An argument is possibly null but the parameter type doesn't admit null. |
MIR0105 | PossiblyInvalidArgument | An argument may not match the parameter type on some code paths. |
MIR0106 | PossiblyNullPropertyFetch | A property is fetched from a value that may be null. |
MIR0107 | PossiblyNullMethodCall | A method is called on a value that may be null. |
MIR0108 | PossiblyNullArrayAccess | Array access on a value that may be null. |
MIR0109 | NullableReturnStatement | A nullable value is returned from a function with a non-nullable return type. |
Type mismatches
| Code | Issue | Description |
|---|---|---|
MIR0110 | LessSpecificReturnStatement | A returned value's type is wider than the declared return type that it may still satisfy. |
MIR0200 | InvalidReturnType | The returned value does not match the declared return type. |
MIR0201 | InvalidArgument | An argument's type does not match the parameter's declared type. |
MIR0202 | TooFewArguments | A call provides fewer arguments than the function requires. |
MIR0203 | TooManyArguments | A call provides more arguments than the function accepts. |
MIR0204 | InvalidNamedArgument | A named argument does not correspond to any parameter of the callable. |
MIR0205 | InvalidPassByReference | A by-reference parameter receives an expression that cannot be referenced. |
MIR0206 | InvalidPropertyAssignment | A value assigned to a property is incompatible with the property's declared type. |
MIR0207 | InvalidCast | A cast from an array or object to a scalar type always produces a meaningless result. |
MIR0208 | InvalidOperand | An operator is applied to incompatible types. |
MIR0209 | MismatchingDocblockReturnType | The @return docblock type conflicts with the native return type hint. |
MIR0210 | MismatchingDocblockParamType | A docblock @param type doesn't match the inferred type from the function body. |
MIR0211 | InvalidStringClass | A string used as a class name does not resolve to a known class. |
MIR0212 | TypeCheckMismatch | A @mir-check assertion in a test fixture does not match the inferred type. |
MIR0213 | PossiblyInvalidOperand | Operator applied to a union type with some incompatible members. |
MIR0214 | PossiblyNullOperand | Operand could be null, making the operation potentially unsafe. |
MIR0215 | InvalidStaticInvocation | Non-static method called with :: syntax. |
MIR0216 | NonStaticSelfCall | self::method() called when the method is not static. |
MIR0217 | DirectConstructorCall | Direct call to __construct() outside of a constructor chain. |
MIR0218 | InvalidPropertyFetch | Property access on a non-object type. |
MIR0219 | InvalidArrayAccess | Array-style access on a non-array, non-string, non-ArrayAccess type. |
MIR0220 | InvalidArrayAssignment | Array-style assignment on a non-array type. |
MIR0221 | Trace | Internal/debug output of the @trace annotation, showing the inferred type of an expression. Not a project diagnostic. |
MIR0222 | RawObjectIteration | An object that does not implement Traversable is iterated (e.g. via foreach or yield from). |
MIR0223 | PossiblyRawObjectIteration | A value that might be a non-iterable object is iterated. |
MIR0224 | InvalidNamedArguments | Named arguments passed to a function or method tagged @no-named-arguments. |
MIR0225 | ArgumentTypeCoercion | An argument's type had to be widened/coerced to match the parameter's declared type. |
MIR0226 | PropertyTypeCoercion | A value assigned to a property had to be coerced to the property's declared type. |
MIR0227 | PossiblyInvalidArrayAccess | Array access on a value that is only sometimes offset-accessible. |
MIR0228 | NotAnInterface | A class that is expected to be an interface is not an interface. |
MIR0229 | DivisionByZero | A division operation that will always result in division by zero. |
MIR0230 | InvalidMethodCall | Method call on a non-object type. |
MIR0231 | InvalidUnpack | A scalar or null unpacked into a call with .... |
MIR0232 | PossiblyNullPropertyAssignmentValue | A value assigned to a property may be null, which the property's type doesn't accept. |
MIR0233 | PossiblyFalsePropertyAssignmentValue | A value assigned to a property may be false, which the property's type doesn't accept. |
MIR0234 | PossiblyInvalidPropertyAssignmentValue | Only some types of a value assigned to a property match the property's type. |
MIR0235 | InvalidMemberName | An object used as a dynamic property or method name. |
MIR0236 | NativeResourceType | resource used as a native parameter, return or property type. |
MIR0237 | InvalidGeneratorIteration | foreach iterates a generator whose send type does not accept null. |
MIR0238 | InvalidScalarArgument | A scalar argument of another scalar type is passed in a file without strict_types. |
Array
| Code | Issue | Description |
|---|---|---|
MIR0300 | InvalidArrayOffset | An array is accessed with a key of the wrong type. |
MIR0301 | NonExistentArrayOffset | An array is accessed with a key that is known not to exist. |
MIR0302 | PossiblyInvalidArrayOffset | An array is accessed with a key that might not exist. |
MIR0303 | DuplicateArrayKey | An array literal contains duplicate keys, with later values overwriting earlier ones. |
Redundancy
| Code | Issue | Description |
|---|---|---|
MIR0400 | RedundantCondition | A condition is always true or always false based on the known types. |
MIR0401 | RedundantCast | A value is cast to a type it already has. |
MIR0402 | UnnecessaryVarAnnotation | A @var annotation matches the type that mir already infers. |
MIR0403 | TypeDoesNotContainType | A type check can never be true because the type does not include the tested type. |
MIR0404 | ParadoxicalCondition | Condition that directly contradicts itself (always false). |
MIR0405 | UnhandledMatchCondition | A match has no arm for some possible subject value and no default arm. |
MIR0406 | DocblockTypeContradiction | A docblock-declared type makes a later assertion or comparison impossible (e.g. assert($a < 4) on @param int<5, max> $a). |
MIR0407 | UnevaluatedCode | A switch/match arm can never be reached given the subject's inferred type (e.g. case "int" for gettype(), which returns "integer"). |
MIR0408 | ImpossibleIdenticalComparison | An identical comparison (===) that can never be true due to incompatible types. |
MIR0409 | ImpossibleLooseComparison | A loose comparison (==) that can never be true due to incompatible types. |
Dead code
| Code | Issue | Description |
|---|---|---|
MIR0500 | UnusedVariable | A variable is assigned but never read. |
MIR0501 | UnusedParam | A function parameter is never referenced in the function body. |
MIR0502 | UnreachableCode | Code appears after an unconditional return, throw, or exit. |
MIR0503 | UnusedMethod | A private method is never called within the class. |
MIR0504 | UnusedProperty | A private property is never read within the class. |
MIR0505 | UnusedFunction | A function is defined but never called. |
MIR0506 | UnusedForeachValue | Foreach value variable assigned but never read. |
MIR0507 | UnusedClass | A class is declared but never referenced anywhere in the analyzed code. |
MIR0508 | UnusedSuppress | A suppression annotation (@mir-ignore, @psalm-suppress, @suppress) did not match any issue. |
MIR0509 | UnusedConstant | A private class or enum constant is never used. |
Inheritance
| Code | Issue | Description |
|---|---|---|
MIR0700 | UnimplementedAbstractMethod | A concrete class does not implement an abstract method from its parent. |
MIR0701 | UnimplementedInterfaceMethod | A class does not implement a method required by an interface it declares. |
MIR0702 | MethodSignatureMismatch | An overriding method has a signature incompatible with the parent's. |
MIR0703 | OverriddenMethodAccess | An overriding method reduces the visibility of the parent method. |
MIR0704 | InvalidExtendClass | A class extends a final class, a sealed type it is not listed in, or misses a class an interface requires. |
MIR0705 | FinalMethodOverridden | A subclass overrides a method declared as final in the parent. |
MIR0706 | AbstractInstantiation | An abstract class is being instantiated with new. |
MIR0707 | CircularInheritance | A class participates in a circular extends/implements/use chain. |
MIR0708 | InvalidOverride | Method or property declared #[Override] does not actually override a parent one. |
MIR0709 | InterfaceInstantiation | Instantiating an interface with new. |
MIR0710 | OverriddenPropertyAccess | An overriding property reduces the visibility of the parent property. |
MIR0711 | AbstractMethodCall | An abstract method is invoked where no concrete implementation exists. |
MIR0712 | PropertyTypeRedeclarationMismatch | A property type declaration in a child class is incompatible with the parent. |
MIR0713 | BackedEnumCaseTypeMismatch | A backed enum case has a value of the wrong type. |
MIR0714 | ReadonlyPropertyRedeclarationMismatch | A readonly property in a child class conflicts with the parent's declaration. |
MIR0715 | StaticPropertyRedeclarationMismatch | A static property in a child class conflicts with the parent's declaration. |
MIR0716 | ReadonlyClassExtendsMismatch | A readonly class extends a non-readonly class, which is not allowed. |
MIR0717 | InvalidReadonlyPropertyDeclaration | A readonly property is declared in a way that violates PHP's readonly rules. |
MIR0718 | DuplicateEnumCaseValue | Two cases of a backed enum have the same value. |
MIR0719 | EnumInstantiation | Instantiating an enum with new. |
MIR0720 | TraitInstantiation | Instantiating a trait with new. |
MIR0721 | NonInvariantDocblockPropertyType | A redeclared property's docblock type differs from the parent's. |
Security
| Code | Issue | Description |
|---|---|---|
MIR0800 | TaintedInput | Tainted input reaches a @taint-sink parameter of a kind with no dedicated issue. |
MIR0801 | TaintedHtml | User-controlled input reaches an HTML output sink without sanitization. |
MIR0802 | TaintedSql | User-controlled input reaches a SQL sink without parameterization. |
MIR0803 | TaintedShell | User-controlled input reaches a shell execution sink without escaping. |
MIR0804 | TaintedLlmPrompt | Tainted input reaches a @taint-sink llm_prompt parameter without sanitization. |
MIR0805 | TaintedHeader | User-controlled input reaches header() without validation. |
MIR0806 | TaintedCookie | User-controlled input reaches setcookie() without validation. |
MIR0807 | TaintedSsrf | User-controlled input picks the URL or host the server connects to. |
MIR0808 | TaintedLdap | User-controlled input reaches an LDAP search filter or base DN. |
MIR0809 | TaintedXpath | User-controlled input reaches an XPath expression. |
MIR0810 | TaintedCallable | User-controlled input chooses which function, method or class runs. |
MIR0811 | TaintedFile | User-controlled input reaches a filesystem path. |
MIR0812 | TaintedInclude | User-controlled input picks the file that include or require loads. |
MIR0813 | TaintedEval | User-controlled input reaches eval(). |
MIR0814 | TaintedUnserialize | User-controlled input reaches unserialize(). |
Generics
| Code | Issue | Description |
|---|---|---|
MIR0900 | InvalidTemplateParam | A template argument violates the declared bounds of the type parameter. |
MIR0901 | ShadowedTemplateParam | A template parameter shadows a name from an outer scope (class template hidden by method template). |
MIR0902 | IfThisIsMismatch | A method annotated @if-this-is X<Y> was called on a receiver whose type does not satisfy that constraint. |
Attributes and duplicates
| Code | Issue | Description |
|---|---|---|
MIR1600 | InvalidAttribute | #[Attribute] usage violates target restrictions or argument constraints. |
MIR1601 | UndefinedAttributeClass | Attribute class referenced with #[...] does not exist. |
MIR1602 | DuplicateClass | Two classes with the same fully-qualified name exist in the codebase. |
MIR1603 | DuplicateInterface | An interface with the same name is declared more than once. |
MIR1604 | DuplicateTrait | A trait with the same name is declared more than once. |
MIR1605 | DuplicateEnum | An enum with the same name is declared more than once. |
MIR1606 | DuplicateFunction | A function with the same name is declared more than once. |
Other
| Code | Issue | Description |
|---|---|---|
MIR0600 | ReadonlyPropertyAssignment | A readonly property is assigned after the constructor. |
MIR0601 | ReadonlyPropertyAlreadyInitialized | A readonly property is assigned after it has already been initialized. |
MIR1000 | DeprecatedCall | A function marked @deprecated is called. |
MIR1001 | DeprecatedMethodCall | A method marked @deprecated is called on an instance. |
MIR1002 | DeprecatedMethod | A method declaration is itself marked @deprecated (reported on the method definition, not its call sites). |
MIR1003 | DeprecatedClass | A class marked @deprecated is being instantiated. |
MIR1004 | InternalMethod | A method marked @internal is called from outside its package. |
MIR1005 | DeprecatedProperty | Access to a @deprecated property. |
MIR1006 | DeprecatedInterface | Implementing a @deprecated interface. |
MIR1007 | DeprecatedTrait | Using a @deprecated trait. |
MIR1008 | DeprecatedConstant | Reference to a @deprecated constant. |
MIR1009 | WrongCaseFunction | Function name casing does not match its declaration. |
MIR1010 | WrongCaseMethod | Method name casing does not match its declaration. |
MIR1011 | WrongCaseClass | Class, interface, or enum name casing does not match its declaration. |
MIR1012 | OptionalParameterBeforeRequired | An optional parameter is declared before a required one, which PHP deprecates from 8.0. |
MIR1013 | ImplicitlyNullableParameter | A typed parameter is nullable only through its null default, which PHP deprecates from 8.4. |
MIR1014 | DynamicPropertyCreation | A write creates an undeclared property, which PHP deprecates from 8.2. |
MIR1100 | MissingReturnType | A function or method has no declared return type hint. |
MIR1101 | MissingParamType | A parameter has no declared type hint. |
MIR1102 | MissingThrowsDocblock | A function throws an exception that is not declared in its @throws docblock. |
MIR1103 | InvalidDocblock | A docblock contains a malformed or unrecognised annotation. |
MIR1104 | MissingPropertyType | A class property has no declared type. |
MIR1105 | MissingClosureReturnType | A closure or arrow function has no declared return type. |
MIR1106 | UndefinedThrowsDocblock | A @throws docblock references an exception class that does not exist. |
MIR1107 | InvalidDocblockType | A type in a docblock is invalid or cannot be resolved. |
MIR1200 | MixedArgument | An argument with type mixed is passed to a parameter with a more specific type. |
MIR1201 | MixedAssignment | A value with type mixed is assigned, hiding its concrete type. |
MIR1202 | MixedMethodCall | A method is called on a value of type mixed. |
MIR1203 | MixedPropertyFetch | A property is fetched from a value of type mixed. |
MIR1204 | MixedClone | clone is applied to a value of type mixed. |
MIR1205 | InvalidClone | Cloning a non-object, an enum, or an object whose private __clone() is out of scope. |
MIR1206 | PossiblyInvalidClone | Cloning a value whose type might not be an object. |
MIR1207 | InvalidToString | Using an object in a string context without a __toString method. |
MIR1208 | MixedPropertyAssignment | A mixed value is assigned to a property, hiding its concrete type. |
MIR1209 | MixedArrayAccess | Array access produced a value of type mixed. |
MIR1210 | MixedArrayOffset | An array is indexed with an offset of type mixed. |
MIR1211 | MixedFunctionCall | A dynamic call target has type mixed. |
MIR1212 | MixedReturnStatement | A mixed value is returned from a function with a typed return. |
MIR1300 | InvalidTraitUse | A trait is used in a way that violates its declared constraints. |
MIR1301 | ForbiddenCode | Use of a forbidden construct such as var_dump, shell_exec, or the backtick operator. |
MIR1400 | ParseError | A PHP file could not be parsed. |
MIR1401 | CompileError | PHP rejects the code at compile time. |
MIR1500 | InvalidThrow | A value that does not implement Throwable is thrown. |
MIR1501 | ImplicitToStringCast | An object without __toString or Stringable is implicitly coerced to a string (e.g. in string concatenation). |
MIR1502 | ImplicitFloatToIntCast | A float is implicitly cast to an int, potentially losing precision. |
MIR1503 | InvalidCatch | Catching a type that is not Throwable. |
MIR1504 | NoInterfaceProperties | A property is accessed on an interface that seals properties and does not declare it via @property. |
MIR1505 | UndefinedDocblockClass | A class referenced only in a docblock does not exist. |
MIR1506 | UnsupportedReferenceUsage | A PHP reference assignment is used in a form mir cannot model precisely (e.g. $b = &$arr[$x]). |
MIR1507 | MissingConstructor | A class has non-nullable, uninitialized typed properties but no constructor to initialize them. |
MIR1508 | UnreachableCatch | A catch block is unreachable because a more general exception type is caught before a more specific one. |
MIR1509 | PluginIssue | An issue reported by a custom plugin. |
MIR1510 | PropertyPossiblyUninitialized | A property may not be initialized in all code paths before use. |
MIR1511 | UseStatementHasNoEffect | A use statement imports a single-segment name without an alias outside any namespace. |
MIR1512 | PrivateFinalMethod | A method other than the constructor is declared both private and final. |
MIR1513 | NonPublicMagicMethod | A magic method PHP calls from outside the class is declared protected or private. |
MIR1514 | NoDiscardReturnIgnored | The result of a #[\NoDiscard] function or method is discarded. |
MIR1700 | ImpurePropertyAssignment | A function marked @pure assigns to a property. |
MIR1701 | ImpureMethodCall | A @pure function calls an impure method. |
MIR1702 | ImpureGlobalVariable | A @pure function reads or writes a global variable. |
MIR1703 | ImpureStaticVariable | A @pure function uses a static variable. |
MIR1704 | ImpureFunctionCall | A @pure function calls a non-pure function. |
MIR1705 | ImmutablePropertyModification | An attempt to modify a property on an immutable object. |
MIR1706 | ImpureStaticPropertyAssignment | An impure function assigns to a static property, causing side effects. |
MIR1707 | ImpureByRefAssignment | An impure function modifies a parameter passed by reference, causing side effects. |
MIR1708 | ImpureStaticPropertyAccess | An impure function reads a static property, depending on external state. |
