Skip to content

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-code or <findUnusedVariables>.
  • Info-level issues, mostly redundancies: --show-info.

mir reports 203 kinds of issues.

Undefined

CodeIssueDescription
MIR0001InvalidScope$this used outside a class or inside a static method.
MIR0002UndefinedVariableA variable is used before it has been assigned.
MIR0003UndefinedFunctionA call targets a function that does not exist in the codebase or stubs.
MIR0004UndefinedMethodA method is called on a type that does not declare that method.
MIR0005UndefinedClassA reference is made to a class or interface that does not exist.
MIR0006UndefinedPropertyA property is accessed that is not declared on the class.
MIR0007UndefinedConstantA reference is made to a constant that has not been defined.
MIR0008PossiblyUndefinedVariableA variable is only assigned in some branches and may be unset on other paths.
MIR0009UndefinedTraitA trait is used that does not exist in the codebase or stubs.
MIR0010ParentNotFoundUse of parent:: in a class that has no parent.
MIR0011InaccessibleClassConstantAccess to a private or protected class constant from an incompatible scope.
MIR0012TraitConstantAccessedDirectlyA trait constant is accessed directly, which is not allowed in PHP.
MIR0013UndefinedTraitAliasMethodA method from a trait alias is used but the alias was not properly defined.
MIR0014InaccessiblePropertyAccess to a private or protected property from an incompatible scope.
MIR0015PossiblyUndefinedMethodA method is called on a union where only some members declare it.
MIR0016InvalidDynamicPropertyA write creates an undeclared property on an enum or readonly class, which throws.

Nullability

CodeIssueDescription
MIR0100NullArgumentnull is passed to a parameter that does not accept null.
MIR0101NullPropertyFetchA property is accessed on a value that is possibly null.
MIR0102NullMethodCallA method is called on a value that is possibly null.
MIR0103NullArrayAccessArray access is performed on a value that is possibly null.
MIR0104PossiblyNullArgumentAn argument is possibly null but the parameter type doesn't admit null.
MIR0105PossiblyInvalidArgumentAn argument may not match the parameter type on some code paths.
MIR0106PossiblyNullPropertyFetchA property is fetched from a value that may be null.
MIR0107PossiblyNullMethodCallA method is called on a value that may be null.
MIR0108PossiblyNullArrayAccessArray access on a value that may be null.
MIR0109NullableReturnStatementA nullable value is returned from a function with a non-nullable return type.

Type mismatches

CodeIssueDescription
MIR0110LessSpecificReturnStatementA returned value's type is wider than the declared return type that it may still satisfy.
MIR0200InvalidReturnTypeThe returned value does not match the declared return type.
MIR0201InvalidArgumentAn argument's type does not match the parameter's declared type.
MIR0202TooFewArgumentsA call provides fewer arguments than the function requires.
MIR0203TooManyArgumentsA call provides more arguments than the function accepts.
MIR0204InvalidNamedArgumentA named argument does not correspond to any parameter of the callable.
MIR0205InvalidPassByReferenceA by-reference parameter receives an expression that cannot be referenced.
MIR0206InvalidPropertyAssignmentA value assigned to a property is incompatible with the property's declared type.
MIR0207InvalidCastA cast from an array or object to a scalar type always produces a meaningless result.
MIR0208InvalidOperandAn operator is applied to incompatible types.
MIR0209MismatchingDocblockReturnTypeThe @return docblock type conflicts with the native return type hint.
MIR0210MismatchingDocblockParamTypeA docblock @param type doesn't match the inferred type from the function body.
MIR0211InvalidStringClassA string used as a class name does not resolve to a known class.
MIR0212TypeCheckMismatchA @mir-check assertion in a test fixture does not match the inferred type.
MIR0213PossiblyInvalidOperandOperator applied to a union type with some incompatible members.
MIR0214PossiblyNullOperandOperand could be null, making the operation potentially unsafe.
MIR0215InvalidStaticInvocationNon-static method called with :: syntax.
MIR0216NonStaticSelfCallself::method() called when the method is not static.
MIR0217DirectConstructorCallDirect call to __construct() outside of a constructor chain.
MIR0218InvalidPropertyFetchProperty access on a non-object type.
MIR0219InvalidArrayAccessArray-style access on a non-array, non-string, non-ArrayAccess type.
MIR0220InvalidArrayAssignmentArray-style assignment on a non-array type.
MIR0221TraceInternal/debug output of the @trace annotation, showing the inferred type of an expression. Not a project diagnostic.
MIR0222RawObjectIterationAn object that does not implement Traversable is iterated (e.g. via foreach or yield from).
MIR0223PossiblyRawObjectIterationA value that might be a non-iterable object is iterated.
MIR0224InvalidNamedArgumentsNamed arguments passed to a function or method tagged @no-named-arguments.
MIR0225ArgumentTypeCoercionAn argument's type had to be widened/coerced to match the parameter's declared type.
MIR0226PropertyTypeCoercionA value assigned to a property had to be coerced to the property's declared type.
MIR0227PossiblyInvalidArrayAccessArray access on a value that is only sometimes offset-accessible.
MIR0228NotAnInterfaceA class that is expected to be an interface is not an interface.
MIR0229DivisionByZeroA division operation that will always result in division by zero.
MIR0230InvalidMethodCallMethod call on a non-object type.
MIR0231InvalidUnpackA scalar or null unpacked into a call with ....
MIR0232PossiblyNullPropertyAssignmentValueA value assigned to a property may be null, which the property's type doesn't accept.
MIR0233PossiblyFalsePropertyAssignmentValueA value assigned to a property may be false, which the property's type doesn't accept.
MIR0234PossiblyInvalidPropertyAssignmentValueOnly some types of a value assigned to a property match the property's type.
MIR0235InvalidMemberNameAn object used as a dynamic property or method name.
MIR0236NativeResourceTyperesource used as a native parameter, return or property type.
MIR0237InvalidGeneratorIterationforeach iterates a generator whose send type does not accept null.
MIR0238InvalidScalarArgumentA scalar argument of another scalar type is passed in a file without strict_types.

Array

CodeIssueDescription
MIR0300InvalidArrayOffsetAn array is accessed with a key of the wrong type.
MIR0301NonExistentArrayOffsetAn array is accessed with a key that is known not to exist.
MIR0302PossiblyInvalidArrayOffsetAn array is accessed with a key that might not exist.
MIR0303DuplicateArrayKeyAn array literal contains duplicate keys, with later values overwriting earlier ones.

Redundancy

CodeIssueDescription
MIR0400RedundantConditionA condition is always true or always false based on the known types.
MIR0401RedundantCastA value is cast to a type it already has.
MIR0402UnnecessaryVarAnnotationA @var annotation matches the type that mir already infers.
MIR0403TypeDoesNotContainTypeA type check can never be true because the type does not include the tested type.
MIR0404ParadoxicalConditionCondition that directly contradicts itself (always false).
MIR0405UnhandledMatchConditionA match has no arm for some possible subject value and no default arm.
MIR0406DocblockTypeContradictionA docblock-declared type makes a later assertion or comparison impossible (e.g. assert($a < 4) on @param int<5, max> $a).
MIR0407UnevaluatedCodeA switch/match arm can never be reached given the subject's inferred type (e.g. case "int" for gettype(), which returns "integer").
MIR0408ImpossibleIdenticalComparisonAn identical comparison (===) that can never be true due to incompatible types.
MIR0409ImpossibleLooseComparisonA loose comparison (==) that can never be true due to incompatible types.

Dead code

CodeIssueDescription
MIR0500UnusedVariableA variable is assigned but never read.
MIR0501UnusedParamA function parameter is never referenced in the function body.
MIR0502UnreachableCodeCode appears after an unconditional return, throw, or exit.
MIR0503UnusedMethodA private method is never called within the class.
MIR0504UnusedPropertyA private property is never read within the class.
MIR0505UnusedFunctionA function is defined but never called.
MIR0506UnusedForeachValueForeach value variable assigned but never read.
MIR0507UnusedClassA class is declared but never referenced anywhere in the analyzed code.
MIR0508UnusedSuppressA suppression annotation (@mir-ignore, @psalm-suppress, @suppress) did not match any issue.
MIR0509UnusedConstantA private class or enum constant is never used.

Inheritance

CodeIssueDescription
MIR0700UnimplementedAbstractMethodA concrete class does not implement an abstract method from its parent.
MIR0701UnimplementedInterfaceMethodA class does not implement a method required by an interface it declares.
MIR0702MethodSignatureMismatchAn overriding method has a signature incompatible with the parent's.
MIR0703OverriddenMethodAccessAn overriding method reduces the visibility of the parent method.
MIR0704InvalidExtendClassA class extends a final class, a sealed type it is not listed in, or misses a class an interface requires.
MIR0705FinalMethodOverriddenA subclass overrides a method declared as final in the parent.
MIR0706AbstractInstantiationAn abstract class is being instantiated with new.
MIR0707CircularInheritanceA class participates in a circular extends/implements/use chain.
MIR0708InvalidOverrideMethod or property declared #[Override] does not actually override a parent one.
MIR0709InterfaceInstantiationInstantiating an interface with new.
MIR0710OverriddenPropertyAccessAn overriding property reduces the visibility of the parent property.
MIR0711AbstractMethodCallAn abstract method is invoked where no concrete implementation exists.
MIR0712PropertyTypeRedeclarationMismatchA property type declaration in a child class is incompatible with the parent.
MIR0713BackedEnumCaseTypeMismatchA backed enum case has a value of the wrong type.
MIR0714ReadonlyPropertyRedeclarationMismatchA readonly property in a child class conflicts with the parent's declaration.
MIR0715StaticPropertyRedeclarationMismatchA static property in a child class conflicts with the parent's declaration.
MIR0716ReadonlyClassExtendsMismatchA readonly class extends a non-readonly class, which is not allowed.
MIR0717InvalidReadonlyPropertyDeclarationA readonly property is declared in a way that violates PHP's readonly rules.
MIR0718DuplicateEnumCaseValueTwo cases of a backed enum have the same value.
MIR0719EnumInstantiationInstantiating an enum with new.
MIR0720TraitInstantiationInstantiating a trait with new.
MIR0721NonInvariantDocblockPropertyTypeA redeclared property's docblock type differs from the parent's.

Security

CodeIssueDescription
MIR0800TaintedInputTainted input reaches a @taint-sink parameter of a kind with no dedicated issue.
MIR0801TaintedHtmlUser-controlled input reaches an HTML output sink without sanitization.
MIR0802TaintedSqlUser-controlled input reaches a SQL sink without parameterization.
MIR0803TaintedShellUser-controlled input reaches a shell execution sink without escaping.
MIR0804TaintedLlmPromptTainted input reaches a @taint-sink llm_prompt parameter without sanitization.
MIR0805TaintedHeaderUser-controlled input reaches header() without validation.
MIR0806TaintedCookieUser-controlled input reaches setcookie() without validation.
MIR0807TaintedSsrfUser-controlled input picks the URL or host the server connects to.
MIR0808TaintedLdapUser-controlled input reaches an LDAP search filter or base DN.
MIR0809TaintedXpathUser-controlled input reaches an XPath expression.
MIR0810TaintedCallableUser-controlled input chooses which function, method or class runs.
MIR0811TaintedFileUser-controlled input reaches a filesystem path.
MIR0812TaintedIncludeUser-controlled input picks the file that include or require loads.
MIR0813TaintedEvalUser-controlled input reaches eval().
MIR0814TaintedUnserializeUser-controlled input reaches unserialize().

Generics

CodeIssueDescription
MIR0900InvalidTemplateParamA template argument violates the declared bounds of the type parameter.
MIR0901ShadowedTemplateParamA template parameter shadows a name from an outer scope (class template hidden by method template).
MIR0902IfThisIsMismatchA method annotated @if-this-is X<Y> was called on a receiver whose type does not satisfy that constraint.

Attributes and duplicates

CodeIssueDescription
MIR1600InvalidAttribute#[Attribute] usage violates target restrictions or argument constraints.
MIR1601UndefinedAttributeClassAttribute class referenced with #[...] does not exist.
MIR1602DuplicateClassTwo classes with the same fully-qualified name exist in the codebase.
MIR1603DuplicateInterfaceAn interface with the same name is declared more than once.
MIR1604DuplicateTraitA trait with the same name is declared more than once.
MIR1605DuplicateEnumAn enum with the same name is declared more than once.
MIR1606DuplicateFunctionA function with the same name is declared more than once.

Other

CodeIssueDescription
MIR0600ReadonlyPropertyAssignmentA readonly property is assigned after the constructor.
MIR0601ReadonlyPropertyAlreadyInitializedA readonly property is assigned after it has already been initialized.
MIR1000DeprecatedCallA function marked @deprecated is called.
MIR1001DeprecatedMethodCallA method marked @deprecated is called on an instance.
MIR1002DeprecatedMethodA method declaration is itself marked @deprecated (reported on the method definition, not its call sites).
MIR1003DeprecatedClassA class marked @deprecated is being instantiated.
MIR1004InternalMethodA method marked @internal is called from outside its package.
MIR1005DeprecatedPropertyAccess to a @deprecated property.
MIR1006DeprecatedInterfaceImplementing a @deprecated interface.
MIR1007DeprecatedTraitUsing a @deprecated trait.
MIR1008DeprecatedConstantReference to a @deprecated constant.
MIR1009WrongCaseFunctionFunction name casing does not match its declaration.
MIR1010WrongCaseMethodMethod name casing does not match its declaration.
MIR1011WrongCaseClassClass, interface, or enum name casing does not match its declaration.
MIR1012OptionalParameterBeforeRequiredAn optional parameter is declared before a required one, which PHP deprecates from 8.0.
MIR1013ImplicitlyNullableParameterA typed parameter is nullable only through its null default, which PHP deprecates from 8.4.
MIR1014DynamicPropertyCreationA write creates an undeclared property, which PHP deprecates from 8.2.
MIR1100MissingReturnTypeA function or method has no declared return type hint.
MIR1101MissingParamTypeA parameter has no declared type hint.
MIR1102MissingThrowsDocblockA function throws an exception that is not declared in its @throws docblock.
MIR1103InvalidDocblockA docblock contains a malformed or unrecognised annotation.
MIR1104MissingPropertyTypeA class property has no declared type.
MIR1105MissingClosureReturnTypeA closure or arrow function has no declared return type.
MIR1106UndefinedThrowsDocblockA @throws docblock references an exception class that does not exist.
MIR1107InvalidDocblockTypeA type in a docblock is invalid or cannot be resolved.
MIR1200MixedArgumentAn argument with type mixed is passed to a parameter with a more specific type.
MIR1201MixedAssignmentA value with type mixed is assigned, hiding its concrete type.
MIR1202MixedMethodCallA method is called on a value of type mixed.
MIR1203MixedPropertyFetchA property is fetched from a value of type mixed.
MIR1204MixedCloneclone is applied to a value of type mixed.
MIR1205InvalidCloneCloning a non-object, an enum, or an object whose private __clone() is out of scope.
MIR1206PossiblyInvalidCloneCloning a value whose type might not be an object.
MIR1207InvalidToStringUsing an object in a string context without a __toString method.
MIR1208MixedPropertyAssignmentA mixed value is assigned to a property, hiding its concrete type.
MIR1209MixedArrayAccessArray access produced a value of type mixed.
MIR1210MixedArrayOffsetAn array is indexed with an offset of type mixed.
MIR1211MixedFunctionCallA dynamic call target has type mixed.
MIR1212MixedReturnStatementA mixed value is returned from a function with a typed return.
MIR1300InvalidTraitUseA trait is used in a way that violates its declared constraints.
MIR1301ForbiddenCodeUse of a forbidden construct such as var_dump, shell_exec, or the backtick operator.
MIR1400ParseErrorA PHP file could not be parsed.
MIR1401CompileErrorPHP rejects the code at compile time.
MIR1500InvalidThrowA value that does not implement Throwable is thrown.
MIR1501ImplicitToStringCastAn object without __toString or Stringable is implicitly coerced to a string (e.g. in string concatenation).
MIR1502ImplicitFloatToIntCastA float is implicitly cast to an int, potentially losing precision.
MIR1503InvalidCatchCatching a type that is not Throwable.
MIR1504NoInterfacePropertiesA property is accessed on an interface that seals properties and does not declare it via @property.
MIR1505UndefinedDocblockClassA class referenced only in a docblock does not exist.
MIR1506UnsupportedReferenceUsageA PHP reference assignment is used in a form mir cannot model precisely (e.g. $b = &$arr[$x]).
MIR1507MissingConstructorA class has non-nullable, uninitialized typed properties but no constructor to initialize them.
MIR1508UnreachableCatchA catch block is unreachable because a more general exception type is caught before a more specific one.
MIR1509PluginIssueAn issue reported by a custom plugin.
MIR1510PropertyPossiblyUninitializedA property may not be initialized in all code paths before use.
MIR1511UseStatementHasNoEffectA use statement imports a single-segment name without an alias outside any namespace.
MIR1512PrivateFinalMethodA method other than the constructor is declared both private and final.
MIR1513NonPublicMagicMethodA magic method PHP calls from outside the class is declared protected or private.
MIR1514NoDiscardReturnIgnoredThe result of a #[\NoDiscard] function or method is discarded.
MIR1700ImpurePropertyAssignmentA function marked @pure assigns to a property.
MIR1701ImpureMethodCallA @pure function calls an impure method.
MIR1702ImpureGlobalVariableA @pure function reads or writes a global variable.
MIR1703ImpureStaticVariableA @pure function uses a static variable.
MIR1704ImpureFunctionCallA @pure function calls a non-pure function.
MIR1705ImmutablePropertyModificationAn attempt to modify a property on an immutable object.
MIR1706ImpureStaticPropertyAssignmentAn impure function assigns to a static property, causing side effects.
MIR1707ImpureByRefAssignmentAn impure function modifies a parameter passed by reference, causing side effects.
MIR1708ImpureStaticPropertyAccessAn impure function reads a static property, depending on external state.