1use std::collections::HashSet;
2use std::fmt;
3use std::sync::Arc;
4
5use serde::{Deserialize, Serialize};
6
7mod psalm_levels;
8pub use psalm_levels::psalm_error_level;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
15pub enum Severity {
16 Info,
18 Warning,
20 Error,
22}
23
24impl fmt::Display for Severity {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 match self {
27 Severity::Info => write!(f, "info"),
28 Severity::Warning => write!(f, "warning"),
29 Severity::Error => write!(f, "error"),
30 }
31 }
32}
33
34pub use mir_types::Location;
39
40#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
46pub enum CloneFailure {
47 NonObject,
48 Enum,
49 PrivateMethod {
51 owner: String,
52 scope: Option<String>,
53 },
54}
55
56#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
57#[non_exhaustive]
58pub enum IssueKind {
59 NonStaticSelfCall { class: String, method: String },
65 InvalidScope {
66 in_class: bool,
68 },
69 UndefinedVariable { name: String },
72 UndefinedFunction { name: String },
75 UndefinedMethod { class: String, method: String },
78 PossiblyUndefinedMethod { class: String, method: String },
81 UndefinedClass { name: String },
84 UndefinedProperty { class: String, property: String },
87 InaccessibleProperty { class: String, property: String },
92 UndefinedConstant { name: String },
95 InaccessibleClassConstant { class: String, constant: String },
98 PossiblyUndefinedVariable { name: String },
101 UndefinedTrait { name: String },
104 TraitConstantAccessedDirectly {
111 trait_name: String,
112 constant: String,
113 },
114 UndefinedTraitAliasMethod {
122 trait_name: Option<String>,
123 method: String,
124 },
125 ParentNotFound,
128 InvalidStringClass { actual: String },
131 NotAnInterface { name: String },
135
136 NullArgument { param: String, fn_name: String },
140 NullPropertyFetch { property: String },
143 NullMethodCall { method: String },
146 NullArrayAccess,
149 PossiblyNullArgument { param: String, fn_name: String },
152 PossiblyInvalidArgument {
155 param: String,
156 fn_name: String,
157 expected: String,
158 actual: String,
159 },
160 PossiblyNullPropertyFetch { property: String },
163 PossiblyNullMethodCall { method: String },
166 PossiblyNullArrayAccess,
169 NullableReturnStatement { expected: String, actual: String },
172
173 InvalidReturnType { expected: String, actual: String },
177 InvalidArgument {
180 param: String,
181 fn_name: String,
182 expected: String,
183 actual: String,
184 },
185 TooFewArguments {
188 fn_name: String,
189 expected: usize,
190 actual: usize,
191 },
192 TooManyArguments {
195 fn_name: String,
196 expected: usize,
197 actual: usize,
198 },
199 InvalidNamedArgument {
202 fn_name: String,
203 name: String,
204 overwrites: bool,
205 },
206 InvalidNamedArguments { fn_name: String },
209 InvalidPassByReference { fn_name: String, param: String },
212 InvalidPropertyFetch { ty: String },
215 InvalidMethodCall { method: String, ty: String },
218 InvalidMemberName { member: String, ty: String },
221 NativeResourceType { class: String },
224 InvalidUnpack {
227 ty: String,
229 },
230 InvalidArrayAccess { ty: String },
233 PossiblyInvalidArrayAccess { ty: String },
236 InvalidArrayAssignment { ty: String },
239 InvalidPropertyAssignment {
242 property: String,
243 expected: String,
244 actual: String,
245 },
246 PossiblyNullPropertyAssignmentValue {
249 property: String,
250 expected: String,
251 actual: String,
252 },
253 PossiblyFalsePropertyAssignmentValue {
256 property: String,
257 expected: String,
258 actual: String,
259 },
260 PossiblyInvalidPropertyAssignmentValue {
263 property: String,
264 expected: String,
265 actual: String,
266 },
267 InvalidCast { from: String, to: String },
270 InvalidStaticInvocation { class: String, method: String },
273 InvalidOperand {
277 op: String,
278 left: String,
279 right: String,
280 },
281 PossiblyInvalidOperand {
284 op: String,
285 left: String,
286 right: String,
287 },
288 PossiblyNullOperand { op: String, ty: String },
291 DivisionByZero { op: String },
295 RawObjectIteration { ty: String },
298 PossiblyRawObjectIteration { ty: String },
301 InvalidGeneratorIteration { ty: String, send: String },
305 MismatchingDocblockReturnType { declared: String, inferred: String },
308 MismatchingDocblockParamType {
311 param: String,
312 declared: String,
313 inferred: String,
314 },
315 TypeCheckMismatch {
321 var: String,
322 expected: String,
323 actual: String,
324 },
325
326 Trace { variable: String, type_info: String },
329
330 InvalidArrayOffset { expected: String, actual: String },
334 NonExistentArrayOffset { key: String },
338 PossiblyInvalidArrayOffset { expected: String, actual: String },
341 DuplicateArrayKey { key: String },
346
347 RedundantCondition {
351 always_true: bool,
352 unreachable: Option<String>,
354 },
355 RedundantCast { from: String, to: String },
358 UnnecessaryVarAnnotation { var: String },
361 TypeDoesNotContainType { left: String, right: String },
364 ParadoxicalCondition { value: String },
367 DocblockTypeContradiction { expr: String, declared: String },
372 ImpossibleIdenticalComparison {
378 op: String,
379 left: String,
380 right: String,
381 },
382 ImpossibleLooseComparison {
389 op: String,
390 left: String,
391 right: String,
392 },
393 UnevaluatedCode { reason: String },
400
401 UnusedVariable { name: String },
405 UnusedParam { name: String },
408 UnreachableCode,
411 UnhandledMatchCondition { detail: String },
414 UnusedMethod { class: String, method: String },
417 UnusedProperty { class: String, property: String },
420 UnusedFunction { name: String },
423 UnusedForeachValue { name: String },
426 UnusedClass { class: String },
429 UnusedConstant { class: String, constant: String },
432 UnusedSuppress { kind: String },
436
437 ArgumentTypeCoercion {
440 param: String,
441 fn_name: String,
442 expected: String,
443 actual: String,
444 },
445
446 PropertyTypeCoercion {
449 property: String,
450 expected: String,
451 actual: String,
452 },
453
454 ImpurePropertyAssignment { property: String },
457 ImpureMethodCall { method: String },
459 ImpureGlobalVariable { variable: String },
461 ImpureStaticVariable { variable: String },
463 ImpureStaticPropertyAssignment { class: String, property: String },
467 ImpureStaticPropertyAccess { class: String, property: String },
472 ImpureByRefAssignment { variable: String },
477 ImpureFunctionCall { fn_name: String },
481 ImmutablePropertyModification { receiver: String, property: String },
487
488 ReadonlyPropertyAssignment {
492 class: String,
493 property: String,
494 unset: bool,
495 },
496 ReadonlyPropertyAlreadyInitialized { class: String, property: String },
503
504 UnimplementedAbstractMethod { class: String, method: String },
508 UnimplementedInterfaceMethod {
511 class: String,
512 interface: String,
513 method: String,
514 },
515 MethodSignatureMismatch {
518 class: String,
519 method: String,
520 detail: String,
521 },
522 OverriddenMethodAccess {
525 class: String,
526 method: String,
527 parent: String,
528 visibility: String,
529 },
530 OverriddenPropertyAccess {
533 class: String,
534 property: String,
535 parent: String,
536 visibility: String,
537 },
538 PropertyTypeRedeclarationMismatch {
541 class: String,
542 property: String,
543 parent: String,
544 expected: String,
545 covariant: bool,
547 before_php85: bool,
549 },
550 NonInvariantDocblockPropertyType {
553 class: String,
554 property: String,
555 parent: String,
556 expected: String,
557 actual: String,
558 },
559 ReadonlyPropertyRedeclarationMismatch {
562 parent_class: String,
563 class: String,
564 property: String,
565 parent_readonly: bool,
568 },
569 StaticPropertyRedeclarationMismatch {
572 parent_class: String,
573 class: String,
574 property: String,
575 parent_static: bool,
578 },
579 ReadonlyClassExtendsMismatch {
585 parent: String,
586 child: String,
587 parent_readonly: bool,
590 },
591 InvalidReadonlyPropertyDeclaration { class: String, property: String },
597 BackedEnumCaseTypeMismatch {
600 enum_name: String,
601 case_name: String,
602 expected: String,
603 actual: String,
604 },
605 DuplicateEnumCaseValue {
609 enum_name: String,
610 first_case: String,
611 case_name: String,
612 },
613 DirectConstructorCall { class: String },
616 InvalidExtendClass { parent: String, child: String },
619 FinalMethodOverridden {
622 class: String,
623 method: String,
624 parent: String,
625 },
626 AbstractInstantiation { class: String },
629 AbstractMethodCall { class: String, method: String },
632 InterfaceInstantiation { class: String },
635 EnumInstantiation { class: String },
638 TraitInstantiation { class: String },
641 InvalidDynamicProperty { class: String, property: String },
645 InvalidOverride { class: String, member: String },
650
651 TaintedInput { sink: String },
655 TaintedHtml,
658 TaintedSql,
661 TaintedShell,
664 TaintedLlmPrompt,
668 TaintedHeader,
671 TaintedCookie,
674 TaintedSsrf,
677 TaintedLdap,
680 TaintedXpath,
683 TaintedCallable,
686 TaintedFile,
689 TaintedInclude,
692 TaintedEval,
695 TaintedUnserialize,
698
699 InvalidTemplateParam {
703 name: String,
704 expected_bound: String,
705 actual: String,
706 },
707 ShadowedTemplateParam { name: String },
710 IfThisIsMismatch {
715 class: String,
716 method: String,
717 expected: String,
718 actual: String,
719 },
720
721 DeprecatedCall {
725 name: String,
726 message: Option<Arc<str>>,
727 },
728 DeprecatedProperty {
731 class: String,
732 property: String,
733 message: Option<Arc<str>>,
734 },
735 DeprecatedConstant {
738 class: String,
739 constant: String,
740 message: Option<Arc<str>>,
741 },
742 OptionalParameterBeforeRequired { message: String },
747 ImplicitlyNullableParameter { message: String },
752 DynamicPropertyCreation { class: String, property: String },
756 DeprecatedInterface {
759 name: String,
760 message: Option<Arc<str>>,
761 },
762 DeprecatedTrait {
765 name: String,
766 message: Option<Arc<str>>,
767 },
768 DeprecatedMethodCall {
771 class: String,
772 method: String,
773 message: Option<Arc<str>>,
774 },
775 DeprecatedMethod {
778 class: String,
779 method: String,
780 message: Option<Arc<str>>,
781 },
782 DeprecatedClass {
785 name: String,
786 message: Option<Arc<str>>,
787 },
788 InternalMethod { class: String, method: String },
791 MissingReturnType { fn_name: String },
794 MissingClosureReturnType,
797 MissingParamType { fn_name: String, param: String },
800 MissingPropertyType { class: String, property: String },
803 InvalidThrow { ty: String },
806 InvalidCatch { ty: String },
809 UnreachableCatch { ty: String, shadowed_by: String },
814 MissingThrowsDocblock { class: String },
817 UndefinedThrowsDocblock { name: String },
822 ImplicitToStringCast { class: String },
825 ImplicitFloatToIntCast { from: String },
828 ParseError {
831 message: String,
832 code: String,
834 },
835 CompileError {
838 message: String,
839 code: String,
841 },
842 InvalidDocblock { message: String },
845 InvalidDocblockType { message: String },
852 MixedArgument { param: String, fn_name: String },
855 MixedAssignment { var: String },
858 MixedMethodCall { method: String },
861 UnsupportedReferenceUsage,
864 NoInterfaceProperties { property: String },
868 UndefinedDocblockClass { name: String },
872 MissingConstructor { class: String },
875 PropertyPossiblyUninitialized { class: String, property: String },
887 MixedFunctionCall,
890 MixedReturnStatement { declared: String },
893 MixedPropertyFetch { property: String },
896 MixedPropertyAssignment { property: String },
899 MixedArrayAccess,
902 MixedArrayOffset,
905 MixedClone,
908 InvalidClone { ty: String, reason: CloneFailure },
913 PossiblyInvalidClone { ty: String },
917 InvalidToString { class: String },
921 CircularInheritance { class: String },
924
925 InvalidTraitUse { trait_name: String, reason: String },
929 ForbiddenCode { message: String },
932
933 InvalidAttribute { message: String },
937 UndefinedAttributeClass { name: String },
940
941 WrongCaseFunction { used: String, canonical: String },
945 WrongCaseMethod {
948 class: String,
949 used: String,
950 canonical: String,
951 },
952 WrongCaseClass { used: String, canonical: String },
955 DuplicateClass { name: String },
958 DuplicateInterface { name: String },
961 DuplicateTrait { name: String },
964 DuplicateEnum { name: String },
967 DuplicateFunction { name: String },
970
971 UseStatementHasNoEffect { name: String },
977 PrivateFinalMethod { class: String, method: String },
982 NonPublicMagicMethod { class: String, method: String },
987 NoDiscardReturnIgnored {
991 callee: String,
993 message: Option<String>,
994 },
995
996 PluginIssue { name: String, message: String },
1000}
1001
1002fn append_deprecation_message(base: String, message: &Option<Arc<str>>) -> String {
1003 match message.as_deref().filter(|m| !m.is_empty()) {
1004 Some(msg) => format!("{base}: {msg}"),
1005 None => base,
1006 }
1007}
1008
1009impl IssueKind {
1010 pub fn is_constant_condition(&self) -> bool {
1012 matches!(
1013 self,
1014 IssueKind::RedundantCondition { .. }
1015 | IssueKind::ImpossibleIdenticalComparison { .. }
1016 | IssueKind::ImpossibleLooseComparison { .. }
1017 | IssueKind::TypeDoesNotContainType { .. }
1018 | IssueKind::DocblockTypeContradiction { .. }
1019 | IssueKind::ParadoxicalCondition { .. }
1020 )
1021 }
1022
1023 pub fn default_severity(&self) -> Severity {
1025 match self {
1026 IssueKind::NonStaticSelfCall { .. }
1028 | IssueKind::DirectConstructorCall { .. }
1029 | IssueKind::InvalidScope { .. }
1030 | IssueKind::UndefinedVariable { .. }
1031 | IssueKind::UndefinedFunction { .. }
1032 | IssueKind::UndefinedMethod { .. }
1033 | IssueKind::UndefinedClass { .. }
1034 | IssueKind::NotAnInterface { .. }
1035 | IssueKind::UndefinedConstant { .. }
1036 | IssueKind::InaccessibleClassConstant { .. }
1037 | IssueKind::InaccessibleProperty { .. }
1038 | IssueKind::InvalidReturnType { .. }
1039 | IssueKind::InvalidArgument { .. }
1040 | IssueKind::InvalidUnpack { .. }
1041 | IssueKind::TooFewArguments { .. }
1042 | IssueKind::TooManyArguments { .. }
1043 | IssueKind::InvalidNamedArgument { .. }
1044 | IssueKind::InvalidNamedArguments { .. }
1045 | IssueKind::InvalidPassByReference { .. }
1046 | IssueKind::InvalidThrow { .. }
1047 | IssueKind::InvalidCatch { .. }
1048 | IssueKind::InvalidStaticInvocation { .. }
1049 | IssueKind::UnimplementedAbstractMethod { .. }
1050 | IssueKind::UnimplementedInterfaceMethod { .. }
1051 | IssueKind::MethodSignatureMismatch { .. }
1052 | IssueKind::InvalidExtendClass { .. }
1053 | IssueKind::FinalMethodOverridden { .. }
1054 | IssueKind::OverriddenMethodAccess { .. }
1055 | IssueKind::OverriddenPropertyAccess { .. }
1056 | IssueKind::AbstractInstantiation { .. }
1057 | IssueKind::AbstractMethodCall { .. }
1058 | IssueKind::InterfaceInstantiation { .. }
1059 | IssueKind::EnumInstantiation { .. }
1060 | IssueKind::TraitInstantiation { .. }
1061 | IssueKind::InvalidDynamicProperty { .. }
1062 | IssueKind::InvalidOverride { .. }
1063 | IssueKind::InvalidTemplateParam { .. }
1064 | IssueKind::ReadonlyPropertyAssignment { .. }
1065 | IssueKind::ReadonlyPropertyAlreadyInitialized { .. }
1066 | IssueKind::ParseError { .. }
1067 | IssueKind::CompileError { .. }
1068 | IssueKind::TaintedInput { .. }
1069 | IssueKind::TaintedHtml
1070 | IssueKind::TaintedSql
1071 | IssueKind::TaintedShell
1072 | IssueKind::TaintedLlmPrompt
1073 | IssueKind::TaintedHeader
1074 | IssueKind::TaintedCookie
1075 | IssueKind::TaintedSsrf
1076 | IssueKind::TaintedLdap
1077 | IssueKind::TaintedXpath
1078 | IssueKind::TaintedCallable
1079 | IssueKind::TaintedFile
1080 | IssueKind::TaintedInclude
1081 | IssueKind::TaintedEval
1082 | IssueKind::TaintedUnserialize
1083 | IssueKind::CircularInheritance { .. }
1084 | IssueKind::InvalidTraitUse { .. }
1085 | IssueKind::UndefinedTrait { .. }
1086 | IssueKind::TraitConstantAccessedDirectly { .. }
1087 | IssueKind::UndefinedTraitAliasMethod { .. }
1088 | IssueKind::InvalidClone { .. }
1089 | IssueKind::InvalidToString { .. }
1090 | IssueKind::TypeCheckMismatch { .. }
1091 | IssueKind::PropertyTypeRedeclarationMismatch { .. }
1092 | IssueKind::ReadonlyPropertyRedeclarationMismatch { .. }
1093 | IssueKind::StaticPropertyRedeclarationMismatch { .. }
1094 | IssueKind::ReadonlyClassExtendsMismatch { .. }
1095 | IssueKind::InvalidReadonlyPropertyDeclaration { .. }
1096 | IssueKind::BackedEnumCaseTypeMismatch { .. }
1097 | IssueKind::DuplicateEnumCaseValue { .. }
1098 | IssueKind::DivisionByZero { .. }
1099 | IssueKind::InvalidMemberName { .. }
1100 | IssueKind::NativeResourceType { .. }
1101 | IssueKind::ParentNotFound => Severity::Error,
1102 IssueKind::Trace { .. } => Severity::Info,
1103
1104 IssueKind::NullArgument { .. }
1106 | IssueKind::NullPropertyFetch { .. }
1107 | IssueKind::NullMethodCall { .. }
1108 | IssueKind::NullArrayAccess
1109 | IssueKind::NullableReturnStatement { .. }
1110 | IssueKind::InvalidPropertyFetch { .. }
1111 | IssueKind::InvalidMethodCall { .. }
1112 | IssueKind::InvalidArrayAccess { .. }
1113 | IssueKind::InvalidArrayAssignment { .. }
1114 | IssueKind::InvalidPropertyAssignment { .. }
1115 | IssueKind::InvalidArrayOffset { .. }
1116 | IssueKind::NonExistentArrayOffset { .. }
1117 | IssueKind::PossiblyInvalidArrayOffset { .. }
1118 | IssueKind::UndefinedProperty { .. }
1119 | IssueKind::InvalidOperand { .. }
1120 | IssueKind::ImplicitToStringCast { .. }
1121 | IssueKind::ImplicitFloatToIntCast { .. }
1122 | IssueKind::UnusedVariable { .. }
1123 | IssueKind::UnusedForeachValue { .. }
1124 | IssueKind::ImpurePropertyAssignment { .. }
1125 | IssueKind::ImpureMethodCall { .. }
1126 | IssueKind::ImpureGlobalVariable { .. }
1127 | IssueKind::ImpureStaticVariable { .. }
1128 | IssueKind::ImpureStaticPropertyAssignment { .. }
1129 | IssueKind::ImpureStaticPropertyAccess { .. }
1130 | IssueKind::ImpureFunctionCall { .. }
1131 | IssueKind::ImpureByRefAssignment { .. }
1132 | IssueKind::ImmutablePropertyModification { .. }
1133 | IssueKind::UnsupportedReferenceUsage
1134 | IssueKind::ParadoxicalCondition { .. }
1135 | IssueKind::UnhandledMatchCondition { .. }
1136 | IssueKind::InvalidStringClass { .. }
1137 | IssueKind::ImpossibleIdenticalComparison { .. }
1138 | IssueKind::ImpossibleLooseComparison { .. }
1139 | IssueKind::DuplicateArrayKey { .. }
1140 | IssueKind::ForbiddenCode { .. }
1141 | IssueKind::UndefinedThrowsDocblock { .. }
1142 | IssueKind::InvalidDocblockType { .. }
1143 | IssueKind::UseStatementHasNoEffect { .. }
1144 | IssueKind::PrivateFinalMethod { .. }
1145 | IssueKind::NonPublicMagicMethod { .. }
1146 | IssueKind::NoDiscardReturnIgnored { .. } => Severity::Warning,
1147
1148 IssueKind::PossiblyUndefinedVariable { .. } => Severity::Warning,
1150
1151 IssueKind::PossiblyNullArgument { .. }
1153 | IssueKind::PossiblyInvalidArgument { .. }
1154 | IssueKind::PossiblyNullPropertyFetch { .. }
1155 | IssueKind::PossiblyNullMethodCall { .. }
1156 | IssueKind::PossiblyUndefinedMethod { .. }
1157 | IssueKind::PossiblyNullArrayAccess
1158 | IssueKind::PossiblyInvalidArrayAccess { .. }
1159 | IssueKind::PossiblyInvalidClone { .. }
1160 | IssueKind::PossiblyInvalidOperand { .. }
1161 | IssueKind::PossiblyNullOperand { .. }
1162 | IssueKind::PossiblyRawObjectIteration { .. }
1163 | IssueKind::InvalidGeneratorIteration { .. }
1164 | IssueKind::PossiblyNullPropertyAssignmentValue { .. }
1165 | IssueKind::PossiblyFalsePropertyAssignmentValue { .. }
1166 | IssueKind::PossiblyInvalidPropertyAssignmentValue { .. } => Severity::Info,
1167
1168 IssueKind::RawObjectIteration { .. } => Severity::Warning,
1169
1170 IssueKind::RedundantCondition { .. }
1172 | IssueKind::RedundantCast { .. }
1173 | IssueKind::UnnecessaryVarAnnotation { .. }
1174 | IssueKind::TypeDoesNotContainType { .. }
1175 | IssueKind::DocblockTypeContradiction { .. }
1176 | IssueKind::UnevaluatedCode { .. }
1177 | IssueKind::IfThisIsMismatch { .. }
1178 | IssueKind::UnusedParam { .. }
1179 | IssueKind::UnreachableCode
1180 | IssueKind::UnreachableCatch { .. }
1181 | IssueKind::UnusedMethod { .. }
1182 | IssueKind::UnusedProperty { .. }
1183 | IssueKind::UnusedFunction { .. }
1184 | IssueKind::UnusedClass { .. }
1185 | IssueKind::UnusedConstant { .. }
1186 | IssueKind::UnusedSuppress { .. }
1187 | IssueKind::ArgumentTypeCoercion { .. }
1188 | IssueKind::PropertyTypeCoercion { .. }
1189 | IssueKind::DeprecatedCall { .. }
1190 | IssueKind::DeprecatedProperty { .. }
1191 | IssueKind::DeprecatedConstant { .. }
1192 | IssueKind::OptionalParameterBeforeRequired { .. }
1193 | IssueKind::ImplicitlyNullableParameter { .. }
1194 | IssueKind::DynamicPropertyCreation { .. }
1195 | IssueKind::DeprecatedInterface { .. }
1196 | IssueKind::DeprecatedTrait { .. }
1197 | IssueKind::DeprecatedMethodCall { .. }
1198 | IssueKind::DeprecatedMethod { .. }
1199 | IssueKind::DeprecatedClass { .. }
1200 | IssueKind::InternalMethod { .. }
1201 | IssueKind::MissingReturnType { .. }
1202 | IssueKind::MissingClosureReturnType
1203 | IssueKind::MissingParamType { .. }
1204 | IssueKind::MissingPropertyType { .. }
1205 | IssueKind::MismatchingDocblockReturnType { .. }
1206 | IssueKind::MismatchingDocblockParamType { .. }
1207 | IssueKind::InvalidDocblock { .. }
1208 | IssueKind::InvalidCast { .. }
1209 | IssueKind::MixedArgument { .. }
1210 | IssueKind::MixedAssignment { .. }
1211 | IssueKind::MixedMethodCall { .. }
1212 | IssueKind::NoInterfaceProperties { .. }
1213 | IssueKind::UndefinedDocblockClass { .. }
1214 | IssueKind::MissingConstructor { .. }
1215 | IssueKind::PropertyPossiblyUninitialized { .. }
1216 | IssueKind::MixedFunctionCall
1217 | IssueKind::MixedReturnStatement { .. }
1218 | IssueKind::MixedPropertyFetch { .. }
1219 | IssueKind::MixedPropertyAssignment { .. }
1220 | IssueKind::MixedArrayAccess
1221 | IssueKind::MixedArrayOffset
1222 | IssueKind::MixedClone
1223 | IssueKind::ShadowedTemplateParam { .. }
1224 | IssueKind::MissingThrowsDocblock { .. }
1225 | IssueKind::WrongCaseFunction { .. }
1226 | IssueKind::WrongCaseMethod { .. }
1227 | IssueKind::WrongCaseClass { .. }
1228 | IssueKind::InvalidAttribute { .. }
1229 | IssueKind::UndefinedAttributeClass { .. }
1230 | IssueKind::NonInvariantDocblockPropertyType { .. } => Severity::Info,
1231 IssueKind::DuplicateClass { .. }
1232 | IssueKind::DuplicateInterface { .. }
1233 | IssueKind::DuplicateTrait { .. }
1234 | IssueKind::DuplicateEnum { .. }
1235 | IssueKind::DuplicateFunction { .. } => Severity::Error,
1236 IssueKind::PluginIssue { .. } => Severity::Error,
1239 }
1240 }
1241
1242 pub fn code(&self) -> &'static str {
1272 match self {
1273 IssueKind::NonStaticSelfCall { .. } => "MIR0216",
1275 IssueKind::DirectConstructorCall { .. } => "MIR0217",
1276 IssueKind::InvalidScope { .. } => "MIR0001",
1277 IssueKind::UndefinedVariable { .. } => "MIR0002",
1278 IssueKind::UndefinedFunction { .. } => "MIR0003",
1279 IssueKind::UndefinedMethod { .. } => "MIR0004",
1280 IssueKind::PossiblyUndefinedMethod { .. } => "MIR0015",
1281 IssueKind::InvalidDynamicProperty { .. } => "MIR0016",
1282 IssueKind::UndefinedClass { .. } => "MIR0005",
1283 IssueKind::UndefinedProperty { .. } => "MIR0006",
1284 IssueKind::UndefinedConstant { .. } => "MIR0007",
1285 IssueKind::InaccessibleClassConstant { .. } => "MIR0011",
1286 IssueKind::InaccessibleProperty { .. } => "MIR0014",
1287 IssueKind::TraitConstantAccessedDirectly { .. } => "MIR0012",
1288 IssueKind::UndefinedTraitAliasMethod { .. } => "MIR0013",
1289 IssueKind::PossiblyUndefinedVariable { .. } => "MIR0008",
1290 IssueKind::UndefinedTrait { .. } => "MIR0009",
1291 IssueKind::ParentNotFound => "MIR0010",
1292
1293 IssueKind::NullArgument { .. } => "MIR0100",
1295 IssueKind::NullPropertyFetch { .. } => "MIR0101",
1296 IssueKind::NullMethodCall { .. } => "MIR0102",
1297 IssueKind::NullArrayAccess => "MIR0103",
1298 IssueKind::PossiblyNullArgument { .. } => "MIR0104",
1299 IssueKind::PossiblyInvalidArgument { .. } => "MIR0105",
1300 IssueKind::PossiblyNullPropertyFetch { .. } => "MIR0106",
1301 IssueKind::PossiblyNullMethodCall { .. } => "MIR0107",
1302 IssueKind::PossiblyNullArrayAccess => "MIR0108",
1303 IssueKind::NullableReturnStatement { .. } => "MIR0109",
1304
1305 IssueKind::InvalidReturnType { .. } => "MIR0200",
1307 IssueKind::InvalidArgument { .. } => "MIR0201",
1308 IssueKind::TooFewArguments { .. } => "MIR0202",
1309 IssueKind::TooManyArguments { .. } => "MIR0203",
1310 IssueKind::InvalidNamedArgument { .. } => "MIR0204",
1311 IssueKind::InvalidNamedArguments { .. } => "MIR0224",
1312 IssueKind::InvalidPassByReference { .. } => "MIR0205",
1313 IssueKind::InvalidPropertyFetch { .. } => "MIR0218",
1314 IssueKind::InvalidArrayAccess { .. } => "MIR0219",
1315 IssueKind::PossiblyInvalidArrayAccess { .. } => "MIR0227",
1316 IssueKind::InvalidArrayAssignment { .. } => "MIR0220",
1317 IssueKind::InvalidPropertyAssignment { .. } => "MIR0206",
1318 IssueKind::PossiblyNullPropertyAssignmentValue { .. } => "MIR0232",
1319 IssueKind::PossiblyFalsePropertyAssignmentValue { .. } => "MIR0233",
1320 IssueKind::PossiblyInvalidPropertyAssignmentValue { .. } => "MIR0234",
1321 IssueKind::InvalidCast { .. } => "MIR0207",
1322 IssueKind::InvalidStaticInvocation { .. } => "MIR0215",
1323 IssueKind::InvalidOperand { .. } => "MIR0208",
1324 IssueKind::PossiblyInvalidOperand { .. } => "MIR0213",
1325 IssueKind::PossiblyNullOperand { .. } => "MIR0214",
1326 IssueKind::DivisionByZero { .. } => "MIR0229",
1327 IssueKind::InvalidMethodCall { .. } => "MIR0230",
1328 IssueKind::InvalidMemberName { .. } => "MIR0235",
1329 IssueKind::NativeResourceType { .. } => "MIR0236",
1330 IssueKind::InvalidUnpack { .. } => "MIR0231",
1331 IssueKind::RawObjectIteration { .. } => "MIR0222",
1332 IssueKind::PossiblyRawObjectIteration { .. } => "MIR0223",
1333 IssueKind::InvalidGeneratorIteration { .. } => "MIR0237",
1334 IssueKind::MismatchingDocblockReturnType { .. } => "MIR0209",
1335 IssueKind::MismatchingDocblockParamType { .. } => "MIR0210",
1336 IssueKind::InvalidStringClass { .. } => "MIR0211",
1337 IssueKind::NotAnInterface { .. } => "MIR0228",
1338 IssueKind::TypeCheckMismatch { .. } => "MIR0212",
1339 IssueKind::Trace { .. } => "MIR0221",
1340 IssueKind::ArgumentTypeCoercion { .. } => "MIR0225",
1341 IssueKind::PropertyTypeCoercion { .. } => "MIR0226",
1342
1343 IssueKind::InvalidArrayOffset { .. } => "MIR0300",
1345 IssueKind::NonExistentArrayOffset { .. } => "MIR0301",
1346 IssueKind::PossiblyInvalidArrayOffset { .. } => "MIR0302",
1347 IssueKind::DuplicateArrayKey { .. } => "MIR0303",
1348
1349 IssueKind::RedundantCondition { .. } => "MIR0400",
1351 IssueKind::RedundantCast { .. } => "MIR0401",
1352 IssueKind::UnnecessaryVarAnnotation { .. } => "MIR0402",
1353 IssueKind::TypeDoesNotContainType { .. } => "MIR0403",
1354 IssueKind::ParadoxicalCondition { .. } => "MIR0404",
1355 IssueKind::UnhandledMatchCondition { .. } => "MIR0405",
1356 IssueKind::DocblockTypeContradiction { .. } => "MIR0406",
1357 IssueKind::UnevaluatedCode { .. } => "MIR0407",
1358 IssueKind::ImpossibleIdenticalComparison { .. } => "MIR0408",
1359 IssueKind::ImpossibleLooseComparison { .. } => "MIR0409",
1360
1361 IssueKind::UnusedVariable { .. } => "MIR0500",
1363 IssueKind::UnusedParam { .. } => "MIR0501",
1364 IssueKind::UnreachableCode => "MIR0502",
1365 IssueKind::UnusedMethod { .. } => "MIR0503",
1366 IssueKind::UnusedProperty { .. } => "MIR0504",
1367 IssueKind::UnusedFunction { .. } => "MIR0505",
1368 IssueKind::UnusedForeachValue { .. } => "MIR0506",
1369 IssueKind::UnusedClass { .. } => "MIR0507",
1370 IssueKind::UnusedSuppress { .. } => "MIR0508",
1371 IssueKind::UnusedConstant { .. } => "MIR0509",
1372
1373 IssueKind::ImpurePropertyAssignment { .. } => "MIR1700",
1375 IssueKind::ImpureMethodCall { .. } => "MIR1701",
1376 IssueKind::ImpureGlobalVariable { .. } => "MIR1702",
1377 IssueKind::ImpureStaticVariable { .. } => "MIR1703",
1378 IssueKind::ImpureStaticPropertyAssignment { .. } => "MIR1706",
1379 IssueKind::ImpureByRefAssignment { .. } => "MIR1707",
1380 IssueKind::ImpureStaticPropertyAccess { .. } => "MIR1708",
1381 IssueKind::ImpureFunctionCall { .. } => "MIR1704",
1382 IssueKind::ImmutablePropertyModification { .. } => "MIR1705",
1383 IssueKind::UnsupportedReferenceUsage => "MIR1506",
1384 IssueKind::NoInterfaceProperties { .. } => "MIR1504",
1385 IssueKind::UndefinedDocblockClass { .. } => "MIR1505",
1386 IssueKind::MissingConstructor { .. } => "MIR1507",
1387 IssueKind::PropertyPossiblyUninitialized { .. } => "MIR1510",
1388 IssueKind::MixedFunctionCall => "MIR1211",
1389 IssueKind::MixedReturnStatement { .. } => "MIR1212",
1390
1391 IssueKind::ReadonlyPropertyAssignment { .. } => "MIR0600",
1393 IssueKind::ReadonlyPropertyAlreadyInitialized { .. } => "MIR0601",
1394
1395 IssueKind::UnimplementedAbstractMethod { .. } => "MIR0700",
1397 IssueKind::UnimplementedInterfaceMethod { .. } => "MIR0701",
1398 IssueKind::MethodSignatureMismatch { .. } => "MIR0702",
1399 IssueKind::OverriddenMethodAccess { .. } => "MIR0703",
1400 IssueKind::OverriddenPropertyAccess { .. } => "MIR0710",
1401 IssueKind::PropertyTypeRedeclarationMismatch { .. } => "MIR0712",
1402 IssueKind::BackedEnumCaseTypeMismatch { .. } => "MIR0713",
1403 IssueKind::DuplicateEnumCaseValue { .. } => "MIR0718",
1404 IssueKind::ReadonlyPropertyRedeclarationMismatch { .. } => "MIR0714",
1405 IssueKind::StaticPropertyRedeclarationMismatch { .. } => "MIR0715",
1406 IssueKind::ReadonlyClassExtendsMismatch { .. } => "MIR0716",
1407 IssueKind::InvalidReadonlyPropertyDeclaration { .. } => "MIR0717",
1408 IssueKind::InvalidExtendClass { .. } => "MIR0704",
1409 IssueKind::FinalMethodOverridden { .. } => "MIR0705",
1410 IssueKind::AbstractInstantiation { .. } => "MIR0706",
1411 IssueKind::AbstractMethodCall { .. } => "MIR0711",
1412 IssueKind::InterfaceInstantiation { .. } => "MIR0709",
1413 IssueKind::EnumInstantiation { .. } => "MIR0719",
1414 IssueKind::TraitInstantiation { .. } => "MIR0720",
1415 IssueKind::NonInvariantDocblockPropertyType { .. } => "MIR0721",
1416 IssueKind::CircularInheritance { .. } => "MIR0707",
1417 IssueKind::InvalidOverride { .. } => "MIR0708",
1418
1419 IssueKind::TaintedInput { .. } => "MIR0800",
1421 IssueKind::TaintedHtml => "MIR0801",
1422 IssueKind::TaintedSql => "MIR0802",
1423 IssueKind::TaintedShell => "MIR0803",
1424 IssueKind::TaintedLlmPrompt => "MIR0804",
1425 IssueKind::TaintedHeader => "MIR0805",
1426 IssueKind::TaintedCookie => "MIR0806",
1427 IssueKind::TaintedSsrf => "MIR0807",
1428 IssueKind::TaintedLdap => "MIR0808",
1429 IssueKind::TaintedXpath => "MIR0809",
1430 IssueKind::TaintedCallable => "MIR0810",
1431 IssueKind::TaintedFile => "MIR0811",
1432 IssueKind::TaintedInclude => "MIR0812",
1433 IssueKind::TaintedEval => "MIR0813",
1434 IssueKind::TaintedUnserialize => "MIR0814",
1435
1436 IssueKind::InvalidTemplateParam { .. } => "MIR0900",
1438 IssueKind::ShadowedTemplateParam { .. } => "MIR0901",
1439 IssueKind::IfThisIsMismatch { .. } => "MIR0902",
1440
1441 IssueKind::DeprecatedCall { .. } => "MIR1000",
1443 IssueKind::WrongCaseFunction { .. } => "MIR1009",
1444 IssueKind::WrongCaseMethod { .. } => "MIR1010",
1445 IssueKind::WrongCaseClass { .. } => "MIR1011",
1446 IssueKind::DeprecatedProperty { .. } => "MIR1005",
1447 IssueKind::DeprecatedInterface { .. } => "MIR1006",
1448 IssueKind::DeprecatedTrait { .. } => "MIR1007",
1449 IssueKind::DeprecatedConstant { .. } => "MIR1008",
1450 IssueKind::DeprecatedMethodCall { .. } => "MIR1001",
1451 IssueKind::DeprecatedMethod { .. } => "MIR1002",
1452 IssueKind::DeprecatedClass { .. } => "MIR1003",
1453 IssueKind::InternalMethod { .. } => "MIR1004",
1454 IssueKind::OptionalParameterBeforeRequired { .. } => "MIR1012",
1455 IssueKind::ImplicitlyNullableParameter { .. } => "MIR1013",
1456 IssueKind::DynamicPropertyCreation { .. } => "MIR1014",
1457
1458 IssueKind::MissingReturnType { .. } => "MIR1100",
1460 IssueKind::MissingParamType { .. } => "MIR1101",
1461 IssueKind::MissingPropertyType { .. } => "MIR1104",
1462 IssueKind::MissingClosureReturnType => "MIR1105",
1463 IssueKind::MissingThrowsDocblock { .. } => "MIR1102",
1464 IssueKind::InvalidDocblock { .. } => "MIR1103",
1465 IssueKind::UndefinedThrowsDocblock { .. } => "MIR1106",
1466 IssueKind::InvalidDocblockType { .. } => "MIR1107",
1467
1468 IssueKind::MixedArgument { .. } => "MIR1200",
1470 IssueKind::MixedAssignment { .. } => "MIR1201",
1471 IssueKind::MixedMethodCall { .. } => "MIR1202",
1472 IssueKind::MixedPropertyFetch { .. } => "MIR1203",
1473 IssueKind::MixedPropertyAssignment { .. } => "MIR1208",
1474 IssueKind::MixedArrayAccess => "MIR1209",
1475 IssueKind::MixedArrayOffset => "MIR1210",
1476 IssueKind::MixedClone => "MIR1204",
1477 IssueKind::InvalidClone { .. } => "MIR1205",
1478 IssueKind::PossiblyInvalidClone { .. } => "MIR1206",
1479 IssueKind::InvalidToString { .. } => "MIR1207",
1480
1481 IssueKind::InvalidTraitUse { .. } => "MIR1300",
1483 IssueKind::ForbiddenCode { .. } => "MIR1301",
1484
1485 IssueKind::ParseError { .. } => "MIR1400",
1487 IssueKind::CompileError { .. } => "MIR1401",
1488
1489 IssueKind::InvalidAttribute { .. } => "MIR1600",
1491 IssueKind::UndefinedAttributeClass { .. } => "MIR1601",
1492 IssueKind::DuplicateClass { .. } => "MIR1602",
1493 IssueKind::DuplicateInterface { .. } => "MIR1603",
1494 IssueKind::DuplicateTrait { .. } => "MIR1604",
1495 IssueKind::DuplicateEnum { .. } => "MIR1605",
1496 IssueKind::DuplicateFunction { .. } => "MIR1606",
1497
1498 IssueKind::InvalidThrow { .. } => "MIR1500",
1500 IssueKind::InvalidCatch { .. } => "MIR1503",
1501 IssueKind::UnreachableCatch { .. } => "MIR1508",
1502 IssueKind::PluginIssue { .. } => "MIR1509",
1503 IssueKind::ImplicitToStringCast { .. } => "MIR1501",
1504 IssueKind::ImplicitFloatToIntCast { .. } => "MIR1502",
1505 IssueKind::UseStatementHasNoEffect { .. } => "MIR1511",
1506 IssueKind::PrivateFinalMethod { .. } => "MIR1512",
1507 IssueKind::NonPublicMagicMethod { .. } => "MIR1513",
1508 IssueKind::NoDiscardReturnIgnored { .. } => "MIR1514",
1509 }
1510 }
1511
1512 pub fn default_severity_for_code(code: &str) -> Option<Severity> {
1518 match code {
1519 "MIR0001" | "MIR0002" | "MIR0003" | "MIR0004" | "MIR0005" | "MIR0007" | "MIR0009"
1521 | "MIR0010" | "MIR0011" | "MIR0012" | "MIR0013" | "MIR0014" | "MIR0016" | "MIR0200"
1522 | "MIR0201" | "MIR0202" | "MIR0203" | "MIR0204" | "MIR0205" | "MIR0212" | "MIR0215"
1523 | "MIR0216" | "MIR0217" | "MIR0224" | "MIR0231" | "MIR0235" | "MIR0236" | "MIR0600"
1524 | "MIR0601" | "MIR0700" | "MIR0701" | "MIR0702" | "MIR0703" | "MIR0704" | "MIR0705"
1525 | "MIR0706" | "MIR0707" | "MIR0708" | "MIR0709" | "MIR0710" | "MIR0711" | "MIR0712"
1526 | "MIR0713" | "MIR0714" | "MIR0715" | "MIR0716" | "MIR0717" | "MIR0718" | "MIR0719"
1527 | "MIR0720" | "MIR0228" | "MIR0229" | "MIR0800" | "MIR0801" | "MIR0802" | "MIR0803"
1528 | "MIR0804" | "MIR0805" | "MIR0806" | "MIR0807" | "MIR0808" | "MIR0809" | "MIR0810"
1529 | "MIR0811" | "MIR0812" | "MIR0813" | "MIR0814" | "MIR0900" | "MIR1205" | "MIR1207"
1530 | "MIR1300" | "MIR1400" | "MIR1401" | "MIR1500" | "MIR1503" | "MIR1602" | "MIR1603"
1531 | "MIR1604" | "MIR1605" | "MIR1606" => Some(Severity::Error),
1532
1533 "MIR0006" | "MIR0008" | "MIR0100" | "MIR0101" | "MIR0102" | "MIR0103" | "MIR0109"
1535 | "MIR0206" | "MIR0208" | "MIR0211" | "MIR0218" | "MIR0230" | "MIR0219" | "MIR0220"
1536 | "MIR0222" | "MIR0300" | "MIR0301" | "MIR0302" | "MIR0303" | "MIR0404" | "MIR0405"
1537 | "MIR0408" | "MIR0500" | "MIR0506" | "MIR1301" | "MIR1501" | "MIR1502" | "MIR1700"
1538 | "MIR1701" | "MIR1702" | "MIR1703" | "MIR1704" | "MIR1705" | "MIR1706" | "MIR1707"
1539 | "MIR1708" | "MIR1506" | "MIR1106" | "MIR1107" | "MIR1511" | "MIR1512" | "MIR1513"
1540 | "MIR1514" => Some(Severity::Warning),
1541
1542 "MIR0015" | "MIR0104" | "MIR0105" | "MIR0106" | "MIR0107" | "MIR0108" | "MIR0207"
1544 | "MIR0232" | "MIR0233" | "MIR0234" | "MIR0209" | "MIR0210" | "MIR0213" | "MIR0214"
1545 | "MIR0221" | "MIR0223" | "MIR0400" | "MIR0401" | "MIR0402" | "MIR0403" | "MIR0501"
1546 | "MIR0502" | "MIR0503" | "MIR0504" | "MIR0505" | "MIR0507" | "MIR0508" | "MIR0509"
1547 | "MIR0901" | "MIR1000" | "MIR1001" | "MIR1002" | "MIR1003" | "MIR1004" | "MIR1005"
1548 | "MIR1006" | "MIR1007" | "MIR1008" | "MIR1009" | "MIR1010" | "MIR1011" | "MIR1012"
1549 | "MIR1013" | "MIR1014" | "MIR1100" | "MIR1101" | "MIR1102" | "MIR1103" | "MIR1104"
1550 | "MIR1105" | "MIR1200" | "MIR1201" | "MIR1202" | "MIR1203" | "MIR1204" | "MIR1206"
1551 | "MIR1208" | "MIR1209" | "MIR1210" | "MIR1211" | "MIR1212" | "MIR1504" | "MIR1505"
1552 | "MIR1507" | "MIR1508" | "MIR1600" | "MIR1601" | "MIR0225" | "MIR0226" | "MIR0227"
1553 | "MIR0406" | "MIR0407" | "MIR0902" | "MIR1510" | "MIR0721" | "MIR0237" => {
1554 Some(Severity::Info)
1555 }
1556
1557 _ => None,
1558 }
1559 }
1560
1561 pub fn name(&self) -> &'static str {
1563 match self {
1564 IssueKind::NonStaticSelfCall { .. } => "NonStaticSelfCall",
1565 IssueKind::DirectConstructorCall { .. } => "DirectConstructorCall",
1566 IssueKind::InvalidScope { .. } => "InvalidScope",
1567 IssueKind::UndefinedVariable { .. } => "UndefinedVariable",
1568 IssueKind::UndefinedFunction { .. } => "UndefinedFunction",
1569 IssueKind::UndefinedMethod { .. } => "UndefinedMethod",
1570 IssueKind::PossiblyUndefinedMethod { .. } => "PossiblyUndefinedMethod",
1571 IssueKind::UndefinedClass { .. } => "UndefinedClass",
1572 IssueKind::UndefinedProperty { .. } => "UndefinedProperty",
1573 IssueKind::UndefinedConstant { .. } => "UndefinedConstant",
1574 IssueKind::InaccessibleClassConstant { .. } => "InaccessibleClassConstant",
1575 IssueKind::InaccessibleProperty { .. } => "InaccessibleProperty",
1576 IssueKind::TraitConstantAccessedDirectly { .. } => "TraitConstantAccessedDirectly",
1577 IssueKind::UndefinedTraitAliasMethod { .. } => "UndefinedTraitAliasMethod",
1578 IssueKind::PossiblyUndefinedVariable { .. } => "PossiblyUndefinedVariable",
1579 IssueKind::UndefinedTrait { .. } => "UndefinedTrait",
1580 IssueKind::ParentNotFound => "ParentNotFound",
1581 IssueKind::InvalidStringClass { .. } => "InvalidStringClass",
1582 IssueKind::NotAnInterface { .. } => "NotAnInterface",
1583 IssueKind::NullArgument { .. } => "NullArgument",
1584 IssueKind::NullPropertyFetch { .. } => "NullPropertyFetch",
1585 IssueKind::NullMethodCall { .. } => "NullMethodCall",
1586 IssueKind::NullArrayAccess => "NullArrayAccess",
1587 IssueKind::PossiblyNullArgument { .. } => "PossiblyNullArgument",
1588 IssueKind::PossiblyInvalidArgument { .. } => "PossiblyInvalidArgument",
1589 IssueKind::PossiblyNullPropertyFetch { .. } => "PossiblyNullPropertyFetch",
1590 IssueKind::PossiblyNullMethodCall { .. } => "PossiblyNullMethodCall",
1591 IssueKind::PossiblyNullArrayAccess => "PossiblyNullArrayAccess",
1592 IssueKind::NullableReturnStatement { .. } => "NullableReturnStatement",
1593 IssueKind::InvalidReturnType { .. } => "InvalidReturnType",
1594 IssueKind::InvalidArgument { .. } => "InvalidArgument",
1595 IssueKind::TooFewArguments { .. } => "TooFewArguments",
1596 IssueKind::TooManyArguments { .. } => "TooManyArguments",
1597 IssueKind::InvalidNamedArgument { .. } => "InvalidNamedArgument",
1598 IssueKind::InvalidNamedArguments { .. } => "InvalidNamedArguments",
1599 IssueKind::InvalidPassByReference { .. } => "InvalidPassByReference",
1600 IssueKind::InvalidPropertyFetch { .. } => "InvalidPropertyFetch",
1601 IssueKind::InvalidMethodCall { .. } => "InvalidMethodCall",
1602 IssueKind::InvalidMemberName { .. } => "InvalidMemberName",
1603 IssueKind::NativeResourceType { .. } => "NativeResourceType",
1604 IssueKind::InvalidUnpack { .. } => "InvalidUnpack",
1605 IssueKind::InvalidArrayAccess { .. } => "InvalidArrayAccess",
1606 IssueKind::PossiblyInvalidArrayAccess { .. } => "PossiblyInvalidArrayAccess",
1607 IssueKind::InvalidArrayAssignment { .. } => "InvalidArrayAssignment",
1608 IssueKind::InvalidPropertyAssignment { .. } => "InvalidPropertyAssignment",
1609 IssueKind::PossiblyNullPropertyAssignmentValue { .. } => {
1610 "PossiblyNullPropertyAssignmentValue"
1611 }
1612 IssueKind::PossiblyFalsePropertyAssignmentValue { .. } => {
1613 "PossiblyFalsePropertyAssignmentValue"
1614 }
1615 IssueKind::PossiblyInvalidPropertyAssignmentValue { .. } => {
1616 "PossiblyInvalidPropertyAssignmentValue"
1617 }
1618 IssueKind::InvalidCast { .. } => "InvalidCast",
1619 IssueKind::InvalidStaticInvocation { .. } => "InvalidStaticInvocation",
1620 IssueKind::InvalidOperand { .. } => "InvalidOperand",
1621 IssueKind::PossiblyInvalidOperand { .. } => "PossiblyInvalidOperand",
1622 IssueKind::PossiblyNullOperand { .. } => "PossiblyNullOperand",
1623 IssueKind::DivisionByZero { .. } => "DivisionByZero",
1624 IssueKind::RawObjectIteration { .. } => "RawObjectIteration",
1625 IssueKind::PossiblyRawObjectIteration { .. } => "PossiblyRawObjectIteration",
1626 IssueKind::InvalidGeneratorIteration { .. } => "InvalidGeneratorIteration",
1627 IssueKind::MismatchingDocblockReturnType { .. } => "MismatchingDocblockReturnType",
1628 IssueKind::MismatchingDocblockParamType { .. } => "MismatchingDocblockParamType",
1629 IssueKind::TypeCheckMismatch { .. } => "TypeCheckMismatch",
1630 IssueKind::DocblockTypeContradiction { .. } => "DocblockTypeContradiction",
1631 IssueKind::ImpossibleIdenticalComparison { .. } => "ImpossibleIdenticalComparison",
1632 IssueKind::ImpossibleLooseComparison { .. } => "ImpossibleLooseComparison",
1633 IssueKind::UnevaluatedCode { .. } => "UnevaluatedCode",
1634 IssueKind::IfThisIsMismatch { .. } => "IfThisIsMismatch",
1635 IssueKind::Trace { .. } => "Trace",
1636 IssueKind::InvalidArrayOffset { .. } => "InvalidArrayOffset",
1637 IssueKind::NonExistentArrayOffset { .. } => "NonExistentArrayOffset",
1638 IssueKind::PossiblyInvalidArrayOffset { .. } => "PossiblyInvalidArrayOffset",
1639 IssueKind::DuplicateArrayKey { .. } => "DuplicateArrayKey",
1640 IssueKind::RedundantCondition { .. } => "RedundantCondition",
1641 IssueKind::RedundantCast { .. } => "RedundantCast",
1642 IssueKind::UnnecessaryVarAnnotation { .. } => "UnnecessaryVarAnnotation",
1643 IssueKind::TypeDoesNotContainType { .. } => "TypeDoesNotContainType",
1644 IssueKind::ParadoxicalCondition { .. } => "ParadoxicalCondition",
1645 IssueKind::UnhandledMatchCondition { .. } => "UnhandledMatchCondition",
1646 IssueKind::UnusedVariable { .. } => "UnusedVariable",
1647 IssueKind::UnusedParam { .. } => "UnusedParam",
1648 IssueKind::UnreachableCode => "UnreachableCode",
1649 IssueKind::UnusedMethod { .. } => "UnusedMethod",
1650 IssueKind::UnusedProperty { .. } => "UnusedProperty",
1651 IssueKind::UnusedFunction { .. } => "UnusedFunction",
1652 IssueKind::UnusedForeachValue { .. } => "UnusedForeachValue",
1653 IssueKind::UnusedClass { .. } => "UnusedClass",
1654 IssueKind::UnusedConstant { .. } => "UnusedConstant",
1655 IssueKind::UnusedSuppress { .. } => "UnusedSuppress",
1656 IssueKind::ArgumentTypeCoercion { .. } => "ArgumentTypeCoercion",
1657 IssueKind::PropertyTypeCoercion { .. } => "PropertyTypeCoercion",
1658 IssueKind::ImpurePropertyAssignment { .. } => "ImpurePropertyAssignment",
1659 IssueKind::ImpureMethodCall { .. } => "ImpureMethodCall",
1660 IssueKind::ImpureGlobalVariable { .. } => "ImpureGlobalVariable",
1661 IssueKind::ImpureStaticVariable { .. } => "ImpureStaticVariable",
1662 IssueKind::ImpureByRefAssignment { .. } => "ImpureByRefAssignment",
1663 IssueKind::ImpureStaticPropertyAssignment { .. } => "ImpureStaticPropertyAssignment",
1664 IssueKind::ImpureStaticPropertyAccess { .. } => "ImpureStaticPropertyAccess",
1665 IssueKind::ImpureFunctionCall { .. } => "ImpureFunctionCall",
1666 IssueKind::ImmutablePropertyModification { .. } => "ImmutablePropertyModification",
1667 IssueKind::UnsupportedReferenceUsage => "UnsupportedReferenceUsage",
1668 IssueKind::NoInterfaceProperties { .. } => "NoInterfaceProperties",
1669 IssueKind::UndefinedDocblockClass { .. } => "UndefinedDocblockClass",
1670 IssueKind::MissingConstructor { .. } => "MissingConstructor",
1671 IssueKind::PropertyPossiblyUninitialized { .. } => "PropertyPossiblyUninitialized",
1672 IssueKind::MixedFunctionCall => "MixedFunctionCall",
1673 IssueKind::MixedReturnStatement { .. } => "MixedReturnStatement",
1674 IssueKind::UnimplementedAbstractMethod { .. } => "UnimplementedAbstractMethod",
1675 IssueKind::UnimplementedInterfaceMethod { .. } => "UnimplementedInterfaceMethod",
1676 IssueKind::MethodSignatureMismatch { .. } => "MethodSignatureMismatch",
1677 IssueKind::OverriddenMethodAccess { .. } => "OverriddenMethodAccess",
1678 IssueKind::OverriddenPropertyAccess { .. } => "OverriddenPropertyAccess",
1679 IssueKind::PropertyTypeRedeclarationMismatch { .. } => {
1680 "PropertyTypeRedeclarationMismatch"
1681 }
1682 IssueKind::NonInvariantDocblockPropertyType { .. } => {
1683 "NonInvariantDocblockPropertyType"
1684 }
1685 IssueKind::ReadonlyPropertyRedeclarationMismatch { .. } => {
1686 "ReadonlyPropertyRedeclarationMismatch"
1687 }
1688 IssueKind::StaticPropertyRedeclarationMismatch { .. } => {
1689 "StaticPropertyRedeclarationMismatch"
1690 }
1691 IssueKind::ReadonlyClassExtendsMismatch { .. } => "ReadonlyClassExtendsMismatch",
1692 IssueKind::InvalidReadonlyPropertyDeclaration { .. } => {
1693 "InvalidReadonlyPropertyDeclaration"
1694 }
1695 IssueKind::BackedEnumCaseTypeMismatch { .. } => "BackedEnumCaseTypeMismatch",
1696 IssueKind::DuplicateEnumCaseValue { .. } => "DuplicateEnumCaseValue",
1697 IssueKind::InvalidExtendClass { .. } => "InvalidExtendClass",
1698 IssueKind::FinalMethodOverridden { .. } => "FinalMethodOverridden",
1699 IssueKind::AbstractInstantiation { .. } => "AbstractInstantiation",
1700 IssueKind::AbstractMethodCall { .. } => "AbstractMethodCall",
1701 IssueKind::InterfaceInstantiation { .. } => "InterfaceInstantiation",
1702 IssueKind::EnumInstantiation { .. } => "EnumInstantiation",
1703 IssueKind::TraitInstantiation { .. } => "TraitInstantiation",
1704 IssueKind::InvalidDynamicProperty { .. } => "InvalidDynamicProperty",
1705 IssueKind::InvalidOverride { .. } => "InvalidOverride",
1706 IssueKind::ReadonlyPropertyAssignment { .. } => "ReadonlyPropertyAssignment",
1707 IssueKind::ReadonlyPropertyAlreadyInitialized { .. } => {
1708 "ReadonlyPropertyAlreadyInitialized"
1709 }
1710 IssueKind::InvalidTemplateParam { .. } => "InvalidTemplateParam",
1711 IssueKind::ShadowedTemplateParam { .. } => "ShadowedTemplateParam",
1712 IssueKind::TaintedInput { .. } => "TaintedInput",
1713 IssueKind::TaintedHtml => "TaintedHtml",
1714 IssueKind::TaintedSql => "TaintedSql",
1715 IssueKind::TaintedShell => "TaintedShell",
1716 IssueKind::TaintedLlmPrompt => "TaintedLlmPrompt",
1717 IssueKind::TaintedHeader => "TaintedHeader",
1718 IssueKind::TaintedCookie => "TaintedCookie",
1719 IssueKind::TaintedSsrf => "TaintedSsrf",
1720 IssueKind::TaintedLdap => "TaintedLdap",
1721 IssueKind::TaintedXpath => "TaintedXpath",
1722 IssueKind::TaintedCallable => "TaintedCallable",
1723 IssueKind::TaintedFile => "TaintedFile",
1724 IssueKind::TaintedInclude => "TaintedInclude",
1725 IssueKind::TaintedEval => "TaintedEval",
1726 IssueKind::TaintedUnserialize => "TaintedUnserialize",
1727 IssueKind::DeprecatedCall { .. } => "DeprecatedCall",
1728 IssueKind::DeprecatedProperty { .. } => "DeprecatedProperty",
1729 IssueKind::DeprecatedConstant { .. } => "DeprecatedConstant",
1730 IssueKind::DeprecatedInterface { .. } => "DeprecatedInterface",
1731 IssueKind::DeprecatedTrait { .. } => "DeprecatedTrait",
1732 IssueKind::DeprecatedMethodCall { .. } => "DeprecatedMethodCall",
1733 IssueKind::DeprecatedMethod { .. } => "DeprecatedMethod",
1734 IssueKind::DeprecatedClass { .. } => "DeprecatedClass",
1735 IssueKind::InternalMethod { .. } => "InternalMethod",
1736 IssueKind::OptionalParameterBeforeRequired { .. } => "OptionalParameterBeforeRequired",
1737 IssueKind::ImplicitlyNullableParameter { .. } => "ImplicitlyNullableParameter",
1738 IssueKind::DynamicPropertyCreation { .. } => "DynamicPropertyCreation",
1739 IssueKind::MissingReturnType { .. } => "MissingReturnType",
1740 IssueKind::MissingClosureReturnType => "MissingClosureReturnType",
1741 IssueKind::MissingParamType { .. } => "MissingParamType",
1742 IssueKind::MissingPropertyType { .. } => "MissingPropertyType",
1743 IssueKind::InvalidThrow { .. } => "InvalidThrow",
1744 IssueKind::InvalidCatch { .. } => "InvalidCatch",
1745 IssueKind::UnreachableCatch { .. } => "UnreachableCatch",
1746 IssueKind::MissingThrowsDocblock { .. } => "MissingThrowsDocblock",
1747 IssueKind::ImplicitToStringCast { .. } => "ImplicitToStringCast",
1748 IssueKind::ImplicitFloatToIntCast { .. } => "ImplicitFloatToIntCast",
1749 IssueKind::ParseError { .. } => "ParseError",
1750 IssueKind::CompileError { .. } => "CompileError",
1751 IssueKind::InvalidDocblock { .. } => "InvalidDocblock",
1752 IssueKind::UndefinedThrowsDocblock { .. } => "UndefinedThrowsDocblock",
1753 IssueKind::InvalidDocblockType { .. } => "InvalidDocblockType",
1754 IssueKind::MixedArgument { .. } => "MixedArgument",
1755 IssueKind::MixedAssignment { .. } => "MixedAssignment",
1756 IssueKind::MixedMethodCall { .. } => "MixedMethodCall",
1757 IssueKind::MixedPropertyFetch { .. } => "MixedPropertyFetch",
1758 IssueKind::MixedPropertyAssignment { .. } => "MixedPropertyAssignment",
1759 IssueKind::MixedArrayAccess => "MixedArrayAccess",
1760 IssueKind::MixedArrayOffset => "MixedArrayOffset",
1761 IssueKind::MixedClone => "MixedClone",
1762 IssueKind::InvalidClone { .. } => "InvalidClone",
1763 IssueKind::PossiblyInvalidClone { .. } => "PossiblyInvalidClone",
1764 IssueKind::InvalidToString { .. } => "InvalidToString",
1765 IssueKind::CircularInheritance { .. } => "CircularInheritance",
1766 IssueKind::InvalidTraitUse { .. } => "InvalidTraitUse",
1767 IssueKind::ForbiddenCode { .. } => "ForbiddenCode",
1768 IssueKind::WrongCaseFunction { .. } => "WrongCaseFunction",
1769 IssueKind::WrongCaseMethod { .. } => "WrongCaseMethod",
1770 IssueKind::WrongCaseClass { .. } => "WrongCaseClass",
1771 IssueKind::InvalidAttribute { .. } => "InvalidAttribute",
1772 IssueKind::UndefinedAttributeClass { .. } => "UndefinedAttributeClass",
1773 IssueKind::DuplicateClass { .. } => "DuplicateClass",
1774 IssueKind::DuplicateInterface { .. } => "DuplicateInterface",
1775 IssueKind::DuplicateTrait { .. } => "DuplicateTrait",
1776 IssueKind::DuplicateEnum { .. } => "DuplicateEnum",
1777 IssueKind::DuplicateFunction { .. } => "DuplicateFunction",
1778 IssueKind::UseStatementHasNoEffect { .. } => "UseStatementHasNoEffect",
1779 IssueKind::PrivateFinalMethod { .. } => "PrivateFinalMethod",
1780 IssueKind::NonPublicMagicMethod { .. } => "NonPublicMagicMethod",
1781 IssueKind::NoDiscardReturnIgnored { .. } => "NoDiscardReturnIgnored",
1782 IssueKind::PluginIssue { .. } => "PluginIssue",
1783 }
1784 }
1785
1786 pub fn referenced_symbol(&self) -> Option<String> {
1788 use IssueKind::*;
1789 Some(match self {
1790 UndefinedClass { name }
1791 | UndefinedFunction { name }
1792 | UndefinedConstant { name }
1793 | UndefinedTrait { name }
1794 | UnusedFunction { name }
1795 | DeprecatedCall { name, .. }
1796 | DeprecatedClass { name, .. }
1797 | DeprecatedInterface { name, .. }
1798 | DeprecatedTrait { name, .. } => name.clone(),
1799 UnusedClass { class } => class.clone(),
1800 UndefinedMethod { class, method }
1801 | PossiblyUndefinedMethod { class, method }
1802 | UnusedMethod { class, method }
1803 | InternalMethod { class, method }
1804 | DeprecatedMethod { class, method, .. }
1805 | DeprecatedMethodCall { class, method, .. } => format!("{class}::{method}"),
1806 UndefinedProperty { class, property }
1807 | InaccessibleProperty { class, property }
1808 | UnusedProperty { class, property }
1809 | DeprecatedProperty {
1810 class, property, ..
1811 } => format!("{class}::${property}"),
1812 InaccessibleClassConstant { class, constant }
1813 | UnusedConstant { class, constant }
1814 | DeprecatedConstant {
1815 class, constant, ..
1816 } => format!("{class}::{constant}"),
1817 UndefinedVariable { name }
1818 | PossiblyUndefinedVariable { name }
1819 | UnusedVariable { name } => format!("${name}"),
1820 _ => return None,
1821 })
1822 }
1823
1824 pub fn display_name(&self) -> &str {
1828 match self {
1829 IssueKind::PluginIssue { name, .. } => name,
1830 other => other.name(),
1831 }
1832 }
1833
1834 pub fn message(&self) -> String {
1836 match self {
1837 IssueKind::NonStaticSelfCall { class, method } => {
1838 format!("Non-static method {class}::{method}() cannot be called statically")
1839 }
1840 IssueKind::DirectConstructorCall { class } => {
1841 format!("Cannot call constructor of {class} directly")
1842 }
1843 IssueKind::InvalidScope { in_class } => {
1844 if *in_class {
1845 "$this cannot be used in a static method".to_string()
1846 } else {
1847 "$this cannot be used outside of a class".to_string()
1848 }
1849 }
1850 IssueKind::UndefinedVariable { name } => format!("Variable ${name} is not defined"),
1851 IssueKind::UndefinedFunction { name } => format!("Function {name}() is not defined"),
1852 IssueKind::UndefinedMethod { class, method } => {
1853 format!("Method {class}::{method}() does not exist")
1854 }
1855 IssueKind::PossiblyUndefinedMethod { class, method } => {
1856 format!("Method {class}::{method}() might not exist")
1857 }
1858 IssueKind::UndefinedClass { name } => format!("Class {name} does not exist"),
1859 IssueKind::UndefinedProperty { class, property } => {
1860 format!("Property {class}::${property} does not exist")
1861 }
1862 IssueKind::UndefinedConstant { name } => format!("Constant {name} is not defined"),
1863 IssueKind::InaccessibleClassConstant { class, constant } => {
1864 format!("Cannot access constant {class}::{constant}")
1865 }
1866 IssueKind::InaccessibleProperty { class, property } => {
1867 format!("Cannot access property {class}::${property}")
1868 }
1869 IssueKind::PossiblyUndefinedVariable { name } => {
1870 format!("Variable ${name} might not be defined")
1871 }
1872 IssueKind::UndefinedTrait { name } => format!("Trait {name} does not exist"),
1873 IssueKind::TraitConstantAccessedDirectly {
1874 trait_name,
1875 constant,
1876 } => {
1877 format!("Cannot access trait constant {trait_name}::{constant} directly")
1878 }
1879 IssueKind::UndefinedTraitAliasMethod { trait_name, method } => match trait_name {
1880 Some(t) => {
1881 format!("An alias was defined for {t}::{method} but this method does not exist")
1882 }
1883 None => format!("An alias was defined for {method} but this method does not exist"),
1884 },
1885 IssueKind::ParentNotFound => {
1886 "Cannot use parent:: when current class has no parent".to_string()
1887 }
1888 IssueKind::InvalidStringClass { actual } => {
1889 format!("Dynamic class instantiation requires string or class-string type, got '{actual}'")
1890 }
1891 IssueKind::NotAnInterface { name } => {
1892 format!("{name} is not an interface")
1893 }
1894
1895 IssueKind::NullArgument { param, fn_name } => {
1896 format!("Argument ${param} of {fn_name}() cannot be null")
1897 }
1898 IssueKind::NullPropertyFetch { property } => {
1899 format!("Cannot access property ${property} on null")
1900 }
1901 IssueKind::NullMethodCall { method } => {
1902 format!("Cannot call method {method}() on null")
1903 }
1904 IssueKind::NullArrayAccess => "Cannot access array on null".to_string(),
1905 IssueKind::PossiblyNullArgument { param, fn_name } => {
1906 format!("Argument ${param} of {fn_name}() might be null")
1907 }
1908 IssueKind::PossiblyInvalidArgument {
1909 param,
1910 fn_name,
1911 expected,
1912 actual,
1913 } => {
1914 format!("Argument ${param} of {fn_name}() expects '{expected}', possibly different type '{actual}' provided")
1915 }
1916 IssueKind::PossiblyNullPropertyFetch { property } => {
1917 format!("Cannot access property ${property} on possibly null value")
1918 }
1919 IssueKind::PossiblyNullMethodCall { method } => {
1920 format!("Cannot call method {method}() on possibly null value")
1921 }
1922 IssueKind::PossiblyNullArrayAccess => {
1923 "Cannot access array on possibly null value".to_string()
1924 }
1925 IssueKind::NullableReturnStatement { expected, actual } => {
1926 format!("Return type '{actual}' is not compatible with declared '{expected}'")
1927 }
1928
1929 IssueKind::InvalidReturnType { expected, actual } => {
1930 format!("Return type '{actual}' is not compatible with declared '{expected}'")
1931 }
1932 IssueKind::InvalidArgument {
1933 param,
1934 fn_name,
1935 expected,
1936 actual,
1937 } => {
1938 format!("Argument ${param} of {fn_name}() expects '{expected}', got '{actual}'")
1939 }
1940 IssueKind::TooFewArguments {
1941 fn_name,
1942 expected,
1943 actual,
1944 } => {
1945 format!(
1946 "Too few arguments for {}(): expected {}, got {}",
1947 fn_name, expected, actual
1948 )
1949 }
1950 IssueKind::TooManyArguments {
1951 fn_name,
1952 expected,
1953 actual,
1954 } => {
1955 format!(
1956 "Too many arguments for {}(): expected {}, got {}",
1957 fn_name, expected, actual
1958 )
1959 }
1960 IssueKind::InvalidNamedArgument {
1961 fn_name,
1962 name,
1963 overwrites: true,
1964 } => {
1965 format!(
1966 "{}() argument ${} overwrites a previous argument",
1967 fn_name, name
1968 )
1969 }
1970 IssueKind::InvalidNamedArgument { fn_name, name, .. } => {
1971 format!("{}() has no parameter named ${}", fn_name, name)
1972 }
1973 IssueKind::InvalidNamedArguments { fn_name } => {
1974 format!("{}() does not accept named arguments", fn_name)
1975 }
1976 IssueKind::InvalidPassByReference { fn_name, param } => {
1977 format!(
1978 "Argument ${} of {}() must be passed by reference",
1979 param, fn_name
1980 )
1981 }
1982 IssueKind::InvalidPropertyFetch { ty } => {
1983 format!("Cannot fetch property on non-object type '{ty}'")
1984 }
1985 IssueKind::InvalidMethodCall { method, ty } => {
1986 format!("Cannot call method {method}() on non-object type '{ty}'")
1987 }
1988 IssueKind::InvalidMemberName { member, ty } if member == "method" => {
1989 format!("Method name must be a string, '{ty}' given")
1990 }
1991 IssueKind::InvalidMemberName { member, ty } => {
1992 format!("Object of type '{ty}' cannot be converted to a {member} name")
1993 }
1994 IssueKind::NativeResourceType { class } => {
1995 format!("'resource' is not a native type; PHP reads it as class '{class}', which no resource satisfies")
1996 }
1997 IssueKind::InvalidUnpack { ty } if ty.is_empty() => {
1998 "Only arrays and Traversables can be unpacked".to_string()
1999 }
2000 IssueKind::InvalidUnpack { ty } => {
2001 format!("Only arrays and Traversables can be unpacked, {ty} given")
2002 }
2003 IssueKind::InvalidArrayAccess { ty } => {
2004 format!("Cannot use [] operator on non-array type '{ty}'")
2005 }
2006 IssueKind::PossiblyInvalidArrayAccess { ty } => {
2007 format!("Possibly invalid array access: '{ty}' might not support []")
2008 }
2009 IssueKind::InvalidArrayAssignment { ty } => {
2010 format!("Cannot use [] assignment on non-array type '{ty}'")
2011 }
2012 IssueKind::InvalidPropertyAssignment {
2013 property,
2014 expected,
2015 actual,
2016 } => {
2017 format!("Property ${property} expects '{expected}', cannot assign '{actual}'")
2018 }
2019 IssueKind::PossiblyNullPropertyAssignmentValue {
2020 property,
2021 expected,
2022 actual,
2023 } => {
2024 format!("Property ${property} expects '{expected}', the assigned '{actual}' might be null")
2025 }
2026 IssueKind::PossiblyFalsePropertyAssignmentValue {
2027 property,
2028 expected,
2029 actual,
2030 } => {
2031 format!("Property ${property} expects '{expected}', the assigned '{actual}' might be false")
2032 }
2033 IssueKind::PossiblyInvalidPropertyAssignmentValue {
2034 property,
2035 expected,
2036 actual,
2037 } => {
2038 format!("Property ${property} expects '{expected}', the assigned '{actual}' might not match")
2039 }
2040 IssueKind::InvalidCast { from, to } => {
2041 format!("Cannot cast '{from}' to '{to}'")
2042 }
2043 IssueKind::InvalidStaticInvocation { class, method } => {
2044 format!("Non-static method {class}::{method}() cannot be called statically")
2045 }
2046 IssueKind::InvalidOperand { op, left, right } => {
2047 if right.is_empty() {
2048 format!("Operator '{op}' not supported for operand of type '{left}'")
2049 } else {
2050 format!("Operator '{op}' not supported between '{left}' and '{right}'")
2051 }
2052 }
2053 IssueKind::PossiblyInvalidOperand { op, left, right } => {
2054 format!("Operator '{op}' might not be supported between '{left}' and '{right}'")
2055 }
2056 IssueKind::PossiblyNullOperand { op, ty } => {
2057 format!("Operator '{op}' operand '{ty}' might be null")
2058 }
2059 IssueKind::DivisionByZero { op } => {
2060 format!("Division by zero: right operand of '{op}' is always 0")
2061 }
2062 IssueKind::RawObjectIteration { ty } => {
2063 format!("Cannot iterate over non-iterable object '{ty}'")
2064 }
2065 IssueKind::PossiblyRawObjectIteration { ty } => {
2066 format!("Cannot iterate over possibly non-iterable object '{ty}'")
2067 }
2068 IssueKind::InvalidGeneratorIteration { ty, send } => {
2069 format!("foreach sends null to '{ty}', but its send type is '{send}'")
2070 }
2071 IssueKind::MismatchingDocblockReturnType { declared, inferred } => {
2072 format!("Docblock return type '{declared}' does not match inferred '{inferred}'")
2073 }
2074 IssueKind::MismatchingDocblockParamType {
2075 param,
2076 declared,
2077 inferred,
2078 } => {
2079 format!(
2080 "Docblock type '{declared}' for ${param} does not match inferred '{inferred}'"
2081 )
2082 }
2083 IssueKind::TypeCheckMismatch {
2084 var,
2085 expected,
2086 actual,
2087 } => {
2088 format!("Type of {var} is expected to be {expected}, got {actual}")
2089 }
2090 IssueKind::Trace {
2091 variable,
2092 type_info,
2093 } => {
2094 format!("Type of ${variable} is {type_info}")
2095 }
2096
2097 IssueKind::InvalidArrayOffset { expected, actual } => {
2098 format!("Array offset expects '{expected}', got '{actual}'")
2099 }
2100 IssueKind::NonExistentArrayOffset { key } => {
2101 format!("Array offset '{key}' does not exist")
2102 }
2103 IssueKind::PossiblyInvalidArrayOffset { expected, actual } => {
2104 format!("Array offset might be invalid: expects '{expected}', got '{actual}'")
2105 }
2106 IssueKind::DuplicateArrayKey { key } => {
2107 format!("Array key {key} is duplicated — the earlier entry is silently overwritten")
2108 }
2109
2110 IssueKind::RedundantCondition {
2111 always_true,
2112 unreachable,
2113 } => match unreachable {
2114 Some(branch) => {
2115 format!("Condition is always {always_true}, so the {branch} is never reached")
2116 }
2117 None => format!("Condition is always {always_true}, so the check is redundant"),
2118 },
2119 IssueKind::RedundantCast { from, to } => {
2120 format!("Casting '{from}' to '{to}' is redundant")
2121 }
2122 IssueKind::UnnecessaryVarAnnotation { var } => {
2123 format!("@var annotation for ${var} is unnecessary")
2124 }
2125 IssueKind::TypeDoesNotContainType { left, right } => {
2126 format!("Type '{left}' can never contain type '{right}'")
2127 }
2128 IssueKind::ParadoxicalCondition { value } => {
2129 format!("Value {value} is duplicated; this branch can never be reached")
2130 }
2131 IssueKind::UnhandledMatchCondition { detail } => {
2132 format!("Unhandled match condition: {detail}")
2133 }
2134 IssueKind::DocblockTypeContradiction { expr, declared } => {
2135 format!("Type '{declared}' makes '{expr}' impossible — this can never hold")
2136 }
2137 IssueKind::ImpossibleIdenticalComparison { op, left, right } => {
2138 let result = if op == "===" { "false" } else { "true" };
2139 format!("'{op}' between '{left}' and '{right}' is always {result} — these types can never be identical")
2140 }
2141 IssueKind::ImpossibleLooseComparison { op, left, right } => {
2142 let result = if op == "==" { "false" } else { "true" };
2143 format!("'{op}' between '{left}' and '{right}' is always {result} — these types can never be loosely equal")
2144 }
2145 IssueKind::UnevaluatedCode { reason } => reason.clone(),
2146 IssueKind::IfThisIsMismatch {
2147 class,
2148 method,
2149 expected,
2150 actual,
2151 } => {
2152 format!(
2153 "Cannot call {class}::{method}() — @if-this-is requires $this to be '{expected}', but it is '{actual}'"
2154 )
2155 }
2156
2157 IssueKind::UnusedVariable { name } => format!("Variable ${name} is never read"),
2158 IssueKind::UnusedParam { name } => format!("Parameter ${name} is never used"),
2159 IssueKind::UnreachableCode => "Unreachable code detected".to_string(),
2160 IssueKind::UnusedMethod { class, method } => {
2161 format!("Private method {class}::{method}() is never called")
2162 }
2163 IssueKind::UnusedProperty { class, property } => {
2164 format!("Private property {class}::${property} is never read")
2165 }
2166 IssueKind::UnusedFunction { name } => {
2167 format!("Function {name}() is never called")
2168 }
2169 IssueKind::UnusedForeachValue { name } => {
2170 format!("Foreach value ${name} is never read")
2171 }
2172 IssueKind::UnusedClass { class } => {
2173 format!("Class {class} is never referenced")
2174 }
2175 IssueKind::UnusedConstant { class, constant } => {
2176 format!("Private constant {class}::{constant} is never used")
2177 }
2178 IssueKind::UnusedSuppress { kind } => {
2179 format!("Suppress annotation for '{kind}' is never used")
2180 }
2181 IssueKind::ArgumentTypeCoercion {
2182 param,
2183 fn_name,
2184 expected,
2185 actual,
2186 } => {
2187 format!("Argument ${param} of {fn_name}() expects '{expected}', got '{actual}' — coercion may fail at runtime")
2188 }
2189 IssueKind::PropertyTypeCoercion {
2190 property,
2191 expected,
2192 actual,
2193 } => {
2194 format!("Property ${property} expects '{expected}', cannot assign '{actual}' — coercion may fail at runtime")
2195 }
2196 IssueKind::ImpurePropertyAssignment { property } => {
2197 format!("Assigning to property {property} of a parameter in a pure or external-mutation-free context")
2198 }
2199 IssueKind::ImpureMethodCall { method } => {
2200 format!("Calling impure method {method}() in a pure or immutable context")
2201 }
2202 IssueKind::ImpureGlobalVariable { variable } => {
2203 format!("Using global variable ${variable} in a @pure function")
2204 }
2205 IssueKind::ImpureStaticVariable { variable } => {
2206 format!("Using static variable ${variable} in a @pure function")
2207 }
2208 IssueKind::ImpureByRefAssignment { variable } => {
2209 format!("Assigning to by-reference parameter ${variable} in a @pure function")
2210 }
2211 IssueKind::ImpureStaticPropertyAssignment { class, property } => {
2212 format!("Assigning to static property {class}::${property} in a @pure function")
2213 }
2214 IssueKind::ImpureStaticPropertyAccess { class, property } => {
2215 format!("Reading static property {class}::${property} in a @pure function")
2216 }
2217 IssueKind::ImpureFunctionCall { fn_name } => {
2218 format!("Calling impure function {fn_name}() in a @pure function")
2219 }
2220 IssueKind::ImmutablePropertyModification { receiver, property } => {
2221 format!("Assigning to property {property} of {receiver} in an immutable context (@psalm-immutable class or @psalm-mutation-free method)")
2222 }
2223
2224 IssueKind::UnimplementedAbstractMethod { class, method } => {
2225 format!("Class {class} must implement abstract method {method}()")
2226 }
2227 IssueKind::UnimplementedInterfaceMethod {
2228 class,
2229 interface,
2230 method,
2231 } => {
2232 format!("Class {class} must implement {interface}::{method}() from interface")
2233 }
2234 IssueKind::MethodSignatureMismatch {
2235 class,
2236 method,
2237 detail,
2238 } => {
2239 format!("Method {class}::{method}() signature mismatch: {detail}")
2240 }
2241 IssueKind::OverriddenMethodAccess {
2242 class,
2243 method,
2244 parent,
2245 visibility,
2246 } => {
2247 let weaker = if visibility == "public" {
2248 ""
2249 } else {
2250 " or weaker"
2251 };
2252 format!("Access level to {class}::{method}() must be {visibility} (as in class {parent}){weaker}")
2253 }
2254 IssueKind::OverriddenPropertyAccess {
2255 class,
2256 property,
2257 parent,
2258 visibility,
2259 } => {
2260 let weaker = if visibility == "public" {
2261 ""
2262 } else {
2263 " or weaker"
2264 };
2265 format!("Access level to {class}::${property} must be {visibility} (as in class {parent}){weaker}")
2266 }
2267 IssueKind::PropertyTypeRedeclarationMismatch {
2268 class,
2269 property,
2270 parent,
2271 expected,
2272 covariant,
2273 before_php85,
2274 } => {
2275 if expected.is_empty() && *before_php85 {
2276 format!(
2277 "Type of {class}::${property} must not be defined (as in class {parent})"
2278 )
2279 } else if expected.is_empty() {
2280 format!(
2281 "Type of {class}::${property} must be omitted to match the parent definition in class {parent}"
2282 )
2283 } else {
2284 let subtype = if *covariant { "subtype of " } else { "" };
2285 format!(
2286 "Type of {class}::${property} must be {subtype}{expected} (as in class {parent})"
2287 )
2288 }
2289 }
2290 IssueKind::NonInvariantDocblockPropertyType {
2291 class,
2292 property,
2293 parent,
2294 expected,
2295 actual,
2296 } => format!(
2297 "Docblock type '{actual}' of {class}::${property} is not invariant with '{expected}' in class {parent}"
2298 ),
2299 IssueKind::ReadonlyPropertyRedeclarationMismatch {
2300 parent_class,
2301 class,
2302 property,
2303 parent_readonly,
2304 } => {
2305 if *parent_readonly {
2306 format!(
2307 "Cannot redeclare readonly property {parent_class}::${property} as non-readonly {class}::${property}"
2308 )
2309 } else {
2310 format!(
2311 "Cannot redeclare non-readonly property {parent_class}::${property} as readonly {class}::${property}"
2312 )
2313 }
2314 }
2315 IssueKind::StaticPropertyRedeclarationMismatch {
2316 parent_class,
2317 class,
2318 property,
2319 parent_static,
2320 } => {
2321 if *parent_static {
2322 format!(
2323 "Cannot redeclare static property {parent_class}::${property} as non-static {class}::${property}"
2324 )
2325 } else {
2326 format!(
2327 "Cannot redeclare non-static property {parent_class}::${property} as static {class}::${property}"
2328 )
2329 }
2330 }
2331 IssueKind::BackedEnumCaseTypeMismatch {
2332 expected, actual, ..
2333 } => format!("Enum case type {actual} does not match enum backing type {expected}"),
2334 IssueKind::DuplicateEnumCaseValue {
2335 enum_name,
2336 first_case,
2337 case_name,
2338 } => {
2339 format!(
2340 "Duplicate value in enum {enum_name} for cases {first_case} and {case_name}"
2341 )
2342 }
2343 IssueKind::ReadonlyClassExtendsMismatch {
2344 parent,
2345 child,
2346 parent_readonly,
2347 } => {
2348 if *parent_readonly {
2349 format!("Non-readonly class {child} cannot extend readonly class {parent}")
2350 } else {
2351 format!("Readonly class {child} cannot extend non-readonly class {parent}")
2352 }
2353 }
2354 IssueKind::InvalidReadonlyPropertyDeclaration { class, property } => {
2355 format!("Readonly property {class}::${property} cannot have default value")
2356 }
2357 IssueKind::ReadonlyPropertyAssignment {
2358 class,
2359 property,
2360 unset: true,
2361 } => format!("Cannot unset readonly property {class}::${property}"),
2362 IssueKind::ReadonlyPropertyAssignment {
2363 class, property, ..
2364 } => {
2365 format!(
2366 "Cannot assign to readonly property {class}::${property} outside of constructor"
2367 )
2368 }
2369 IssueKind::ReadonlyPropertyAlreadyInitialized { class, property } => {
2370 format!(
2371 "Cannot modify readonly property {class}::${property} — already initialized"
2372 )
2373 }
2374 IssueKind::InvalidExtendClass { parent, child } => {
2375 format!("Class {child} cannot extend final class {parent}")
2376 }
2377 IssueKind::InvalidTemplateParam {
2378 name,
2379 expected_bound,
2380 actual,
2381 } => {
2382 if actual.split('|').any(|part| part == "false") {
2383 format!(
2384 "Template type '{name}' inferred as '{actual}' can be false and therefore does not satisfy bound '{expected_bound}'"
2385 )
2386 } else {
2387 format!(
2388 "Template type '{name}' inferred as '{actual}' does not satisfy bound '{expected_bound}'"
2389 )
2390 }
2391 }
2392 IssueKind::ShadowedTemplateParam { name } => {
2393 format!(
2394 "Method template parameter '{name}' shadows class-level template parameter with the same name"
2395 )
2396 }
2397 IssueKind::FinalMethodOverridden {
2398 class,
2399 method,
2400 parent,
2401 } => {
2402 format!("Method {class}::{method}() cannot override final method from {parent}")
2403 }
2404 IssueKind::AbstractInstantiation { class } => {
2405 format!("Cannot instantiate abstract class {class}")
2406 }
2407 IssueKind::AbstractMethodCall { class, method } => {
2408 format!("Cannot call abstract method {class}::{method}()")
2409 }
2410 IssueKind::InterfaceInstantiation { class } => {
2411 format!("Cannot instantiate interface {class}")
2412 }
2413 IssueKind::EnumInstantiation { class } => format!("Cannot instantiate enum {class}"),
2414 IssueKind::TraitInstantiation { class } => format!("Cannot instantiate trait {class}"),
2415 IssueKind::InvalidDynamicProperty { class, property } => {
2416 format!("Cannot create dynamic property {class}::${property}")
2417 }
2418 IssueKind::DynamicPropertyCreation { class, property } => {
2419 format!("Creation of dynamic property {class}::${property} is deprecated")
2420 }
2421 IssueKind::InvalidOverride { class, member } => {
2422 let kind = if member.starts_with('$') {
2423 "property"
2424 } else {
2425 "method"
2426 };
2427 format!(
2428 "{class}::{member} has #[\\Override] attribute, but no matching parent {kind} exists"
2429 )
2430 }
2431
2432 IssueKind::TaintedInput { sink } => format!("Tainted input reaching sink '{sink}'"),
2433 IssueKind::TaintedHtml => "Tainted HTML output — possible XSS".to_string(),
2434 IssueKind::TaintedSql => "Tainted SQL query — possible SQL injection".to_string(),
2435 IssueKind::TaintedShell => {
2436 "Tainted shell command — possible command injection".to_string()
2437 }
2438 IssueKind::TaintedLlmPrompt => {
2439 "Tainted LLM prompt — possible prompt injection".to_string()
2440 }
2441 IssueKind::TaintedHeader => {
2442 "Tainted HTTP header — possible header injection or open redirect".to_string()
2443 }
2444 IssueKind::TaintedCookie => "Tainted cookie — possible cookie injection".to_string(),
2445 IssueKind::TaintedSsrf => {
2446 "Tainted URL — possible server-side request forgery".to_string()
2447 }
2448 IssueKind::TaintedLdap => "Tainted LDAP query — possible LDAP injection".to_string(),
2449 IssueKind::TaintedXpath => "Tainted XPath query — possible XPath injection".to_string(),
2450 IssueKind::TaintedCallable => {
2451 "Tainted callable — user input chooses the code that runs".to_string()
2452 }
2453 IssueKind::TaintedFile => "Tainted file path — possible path traversal".to_string(),
2454 IssueKind::TaintedInclude => {
2455 "Tainted include path — possible file inclusion".to_string()
2456 }
2457 IssueKind::TaintedEval => "Tainted eval() code — possible code injection".to_string(),
2458 IssueKind::TaintedUnserialize => {
2459 "Tainted unserialize() payload — possible object injection".to_string()
2460 }
2461
2462 IssueKind::DeprecatedCall { name, message } => {
2463 let base = format!("Call to deprecated function {name}");
2464 append_deprecation_message(base, message)
2465 }
2466 IssueKind::DeprecatedProperty {
2467 class,
2468 property,
2469 message,
2470 } => {
2471 let base = format!("Property {class}::${property} is deprecated");
2472 append_deprecation_message(base, message)
2473 }
2474 IssueKind::DeprecatedConstant {
2475 class,
2476 constant,
2477 message,
2478 } => {
2479 let base = format!("Constant {class}::{constant} is deprecated");
2480 append_deprecation_message(base, message)
2481 }
2482 IssueKind::OptionalParameterBeforeRequired { message }
2483 | IssueKind::ImplicitlyNullableParameter { message } => message.clone(),
2484 IssueKind::DeprecatedInterface { name, message } => {
2485 let base = format!("Interface {name} is deprecated");
2486 append_deprecation_message(base, message)
2487 }
2488 IssueKind::DeprecatedTrait { name, message } => {
2489 let base = format!("Trait {name} is deprecated");
2490 append_deprecation_message(base, message)
2491 }
2492 IssueKind::DeprecatedMethodCall {
2493 class,
2494 method,
2495 message,
2496 } => {
2497 let base = format!("Call to deprecated method {class}::{method}");
2498 append_deprecation_message(base, message)
2499 }
2500 IssueKind::DeprecatedMethod {
2501 class,
2502 method,
2503 message,
2504 } => {
2505 let base = format!("Method {class}::{method}() is deprecated");
2506 append_deprecation_message(base, message)
2507 }
2508 IssueKind::DeprecatedClass { name, message } => {
2509 let base = format!("Class {name} is deprecated");
2510 append_deprecation_message(base, message)
2511 }
2512 IssueKind::InternalMethod { class, method } => {
2513 format!("Method {class}::{method}() is marked @internal")
2514 }
2515 IssueKind::MissingReturnType { fn_name } => {
2516 format!("Function {fn_name}() has no return type annotation")
2517 }
2518 IssueKind::MissingClosureReturnType => {
2519 "Closure has no return type annotation".to_string()
2520 }
2521 IssueKind::MissingParamType { fn_name, param } => {
2522 format!("Parameter ${param} of {fn_name}() has no type annotation")
2523 }
2524 IssueKind::MissingPropertyType { class, property } => {
2525 format!("Property {class}::${property} has no type annotation")
2526 }
2527 IssueKind::InvalidThrow { ty } => {
2528 format!("Thrown type '{ty}' does not extend Throwable")
2529 }
2530 IssueKind::InvalidCatch { ty } => {
2531 format!("Caught type '{ty}' does not extend Throwable")
2532 }
2533 IssueKind::UnreachableCatch { ty, shadowed_by } => {
2534 format!("Catch block for '{ty}' is unreachable — already caught by '{shadowed_by}'")
2535 }
2536 IssueKind::MissingThrowsDocblock { class } => {
2537 format!("Exception {class} is thrown but not declared in @throws")
2538 }
2539 IssueKind::ImplicitToStringCast { class } => {
2540 format!("Class {class} is implicitly cast to string")
2541 }
2542 IssueKind::ImplicitFloatToIntCast { from } => {
2543 format!("Implicit cast from {from} to int truncates the fractional part")
2544 }
2545 IssueKind::ParseError { message, code } => format!("{message} [{code}]"),
2546 IssueKind::CompileError { message, code } => {
2547 format!("{message} [{code}]")
2548 }
2549 IssueKind::InvalidDocblock { message } => message.clone(),
2550 IssueKind::UndefinedThrowsDocblock { name } => {
2551 format!("@throws class '{name}' does not exist")
2552 }
2553 IssueKind::InvalidDocblockType { message } => message.clone(),
2554 IssueKind::MixedArgument { param, fn_name } => {
2555 format!("Argument ${param} of {fn_name}() is mixed")
2556 }
2557 IssueKind::MixedAssignment { var } => {
2558 format!("Variable ${var} is assigned a mixed type")
2559 }
2560 IssueKind::MixedMethodCall { method } => {
2561 format!("Method {method}() called on mixed type")
2562 }
2563 IssueKind::UnsupportedReferenceUsage => {
2564 "Reference assignment is not supported".to_string()
2565 }
2566 IssueKind::NoInterfaceProperties { property } => {
2567 format!("Property ${property} is not defined on this interface")
2568 }
2569 IssueKind::UndefinedDocblockClass { name } => {
2570 format!("Docblock type '{name}' does not exist")
2571 }
2572 IssueKind::MissingConstructor { class } => {
2573 format!("Class {class} has uninitialized properties but no constructor")
2574 }
2575 IssueKind::PropertyPossiblyUninitialized { class, property } => {
2576 format!(
2577 "Property {class}::${property} may be left uninitialized by the constructor"
2578 )
2579 }
2580 IssueKind::MixedFunctionCall => "Cannot call mixed type as a function".to_string(),
2581 IssueKind::MixedReturnStatement { declared } => {
2582 format!("Cannot return a mixed type from function with declared return type '{declared}'")
2583 }
2584 IssueKind::MixedPropertyFetch { property } => {
2585 format!("Property ${property} fetched on mixed type")
2586 }
2587 IssueKind::MixedPropertyAssignment { property } => {
2588 format!("Property ${property} assigned on mixed type")
2589 }
2590 IssueKind::MixedArrayAccess => "Array access on mixed type".to_string(),
2591 IssueKind::MixedArrayOffset => "Mixed type used as array offset".to_string(),
2592 IssueKind::MixedClone => "cannot clone mixed".to_string(),
2593 IssueKind::InvalidClone { ty, reason } => match reason {
2594 CloneFailure::NonObject => format!("cannot clone non-object {ty}"),
2595 CloneFailure::Enum => {
2596 format!("Trying to clone an uncloneable object of class {ty}")
2597 }
2598 CloneFailure::PrivateMethod { owner, scope } => match scope {
2599 Some(scope) => {
2600 format!("Call to private method {owner}::__clone() from scope {scope}")
2601 }
2602 None => format!("Call to private method {owner}::__clone() from global scope"),
2603 },
2604 },
2605 IssueKind::PossiblyInvalidClone { ty } => {
2606 format!("cannot clone possibly non-object {ty}")
2607 }
2608 IssueKind::InvalidToString { class } => {
2609 format!("Method {class}::__toString() must return a string")
2610 }
2611 IssueKind::CircularInheritance { class } => {
2612 format!("Class {class} has a circular inheritance chain")
2613 }
2614 IssueKind::InvalidTraitUse { trait_name, reason } => {
2615 format!("Trait {trait_name} used incorrectly: {reason}")
2616 }
2617 IssueKind::WrongCaseFunction { used, canonical } => {
2618 format!("Function name '{used}' has incorrect casing; use '{canonical}'")
2619 }
2620 IssueKind::WrongCaseMethod {
2621 class,
2622 used,
2623 canonical,
2624 } => {
2625 format!("Method name '{class}::{used}' has incorrect casing; use '{canonical}'")
2626 }
2627 IssueKind::WrongCaseClass { used, canonical } => {
2628 format!("Class name '{used}' has incorrect casing; use '{canonical}'")
2629 }
2630 IssueKind::InvalidAttribute { message } => message.clone(),
2631 IssueKind::UndefinedAttributeClass { name } => {
2632 format!("Attribute class {name} does not exist")
2633 }
2634 IssueKind::ForbiddenCode { message } => message.clone(),
2635 IssueKind::DuplicateClass { name } => {
2636 format!("Class {name} has already been defined")
2637 }
2638 IssueKind::DuplicateInterface { name } => {
2639 format!("Interface {name} has already been defined")
2640 }
2641 IssueKind::DuplicateTrait { name } => {
2642 format!("Trait {name} has already been defined")
2643 }
2644 IssueKind::DuplicateEnum { name } => {
2645 format!("Enum {name} has already been defined")
2646 }
2647 IssueKind::DuplicateFunction { name } => {
2648 format!("Function {name}() has already been defined")
2649 }
2650 IssueKind::UseStatementHasNoEffect { name } => {
2651 format!("The use statement with non-compound name '{name}' has no effect")
2652 }
2653 IssueKind::PrivateFinalMethod { class, method } => {
2654 format!("Private method {class}::{method}() cannot be final as it is never overridden by other classes")
2655 }
2656 IssueKind::NoDiscardReturnIgnored { callee, message } => {
2657 let reason = message.as_deref().map(|m| format!(", {m}")).unwrap_or_default();
2658 format!("The return value of {callee}() should either be used or intentionally ignored by casting it as (void){reason}")
2659 }
2660 IssueKind::NonPublicMagicMethod { class, method } => {
2661 format!("The magic method {class}::{method}() must have public visibility")
2662 }
2663 IssueKind::PluginIssue { message, .. } => message.clone(),
2664 }
2665 }
2666}
2667
2668#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2674pub struct TaintStep {
2675 pub label: String,
2677 pub location: Location,
2678}
2679
2680#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2681pub struct Issue {
2682 pub kind: IssueKind,
2683 pub severity: Severity,
2684 pub location: Location,
2685 pub snippet: Option<String>,
2686 pub suppressed: bool,
2687 #[serde(default)]
2689 pub taint_trace: Option<Box<[TaintStep]>>,
2690}
2691
2692impl Issue {
2693 pub fn new(kind: IssueKind, location: Location) -> Self {
2694 let severity = kind.default_severity();
2695 Self {
2696 severity,
2697 kind,
2698 location,
2699 snippet: None,
2700 suppressed: false,
2701 taint_trace: None,
2702 }
2703 }
2704
2705 pub fn with_snippet(mut self, snippet: impl Into<String>) -> Self {
2706 self.snippet = Some(snippet.into());
2707 self
2708 }
2709
2710 pub fn suppress(mut self) -> Self {
2711 self.suppressed = true;
2712 self
2713 }
2714}
2715
2716#[derive(Debug, Default)]
2721pub struct IssueBuffer {
2722 issues: Vec<Issue>,
2723 seen: HashSet<(&'static str, Arc<str>, u32, u16)>,
2724 file_suppressions: Vec<String>,
2726 discard: bool,
2727}
2728
2729impl IssueBuffer {
2730 pub fn new() -> Self {
2731 Self::default()
2732 }
2733
2734 pub fn discarding(mut self) -> Self {
2735 self.discard = true;
2736 self
2737 }
2738
2739 pub fn is_discarding(&self) -> bool {
2740 self.discard
2741 }
2742
2743 pub fn add(&mut self, issue: Issue) {
2744 if self.discard {
2745 return;
2746 }
2747 let key = (
2748 issue.kind.name(),
2749 issue.location.file.clone(),
2750 issue.location.line,
2751 issue.location.col_start,
2752 );
2753 if self.seen.insert(key) {
2754 self.issues.push(issue);
2755 }
2756 }
2757
2758 pub fn has_impossible_comparison_within(&self, span: &Location) -> bool {
2761 self.issues.iter().any(|i| {
2762 matches!(
2763 i.kind,
2764 IssueKind::ImpossibleIdenticalComparison { .. }
2765 | IssueKind::ImpossibleLooseComparison { .. }
2766 | IssueKind::DocblockTypeContradiction { .. }
2767 | IssueKind::TypeDoesNotContainType { .. }
2768 ) && i.location.file == span.file
2769 && (i.location.line, i.location.col_start) >= (span.line, span.col_start)
2770 && (i.location.line, i.location.col_start) < (span.line_end, span.col_end)
2771 })
2772 }
2773
2774 pub fn add_suppression(&mut self, name: impl Into<String>) {
2775 self.file_suppressions.push(name.into());
2776 }
2777
2778 pub fn into_issues(self) -> Vec<Issue> {
2780 self.issues
2781 .into_iter()
2782 .filter(|i| !i.suppressed)
2783 .filter(|i| {
2784 !self
2785 .file_suppressions
2786 .iter()
2787 .any(|s| s == i.kind.display_name())
2788 })
2789 .collect()
2790 }
2791
2792 pub fn into_all_issues(self) -> Vec<Issue> {
2797 self.issues
2798 .into_iter()
2799 .map(|mut i| {
2800 if self
2801 .file_suppressions
2802 .iter()
2803 .any(|s| s == i.kind.display_name())
2804 {
2805 i.suppressed = true;
2806 }
2807 i
2808 })
2809 .collect()
2810 }
2811
2812 pub fn suppress_range(&mut self, from: usize, suppressions: &[String]) {
2815 if suppressions.is_empty() {
2816 return;
2817 }
2818 for issue in self.issues[from..].iter_mut() {
2819 if suppressions.iter().any(|s| s == issue.kind.display_name()) {
2820 issue.suppressed = true;
2821 }
2822 }
2823 }
2824
2825 pub fn suppress_range_where(&mut self, from: usize, pred: impl Fn(&Issue) -> bool) {
2827 for issue in self.issues[from..].iter_mut().filter(|i| pred(i)) {
2828 issue.suppressed = true;
2829 }
2830 }
2831
2832 pub fn issue_count(&self) -> usize {
2835 self.issues.len()
2836 }
2837
2838 pub fn truncate_to(&mut self, mark: usize) {
2844 for issue in self.issues.drain(mark..) {
2845 let key = (
2846 issue.kind.name(),
2847 issue.location.file.clone(),
2848 issue.location.line,
2849 issue.location.col_start,
2850 );
2851 self.seen.remove(&key);
2852 }
2853 }
2854
2855 pub fn take_since(&mut self, mark: usize, pred: impl Fn(&IssueKind) -> bool) -> Vec<Issue> {
2857 self.take_range(mark, self.issues.len(), pred)
2858 }
2859
2860 pub fn take_range(
2862 &mut self,
2863 mark: usize,
2864 mut end: usize,
2865 pred: impl Fn(&IssueKind) -> bool,
2866 ) -> Vec<Issue> {
2867 let mut taken = Vec::new();
2868 let mut i = mark;
2869 while i < end {
2870 if pred(&self.issues[i].kind) {
2871 let issue = self.issues.remove(i);
2872 self.seen.remove(&(
2873 issue.kind.name(),
2874 issue.location.file.clone(),
2875 issue.location.line,
2876 issue.location.col_start,
2877 ));
2878 end -= 1;
2879 taken.push(issue);
2880 } else {
2881 i += 1;
2882 }
2883 }
2884 taken
2885 }
2886
2887 pub fn is_empty(&self) -> bool {
2888 self.issues.is_empty()
2889 }
2890
2891 pub fn len(&self) -> usize {
2892 self.issues.len()
2893 }
2894
2895 pub fn error_count(&self) -> usize {
2896 self.issues
2897 .iter()
2898 .filter(|i| !i.suppressed && i.severity == Severity::Error)
2899 .count()
2900 }
2901
2902 pub fn warning_count(&self) -> usize {
2903 self.issues
2904 .iter()
2905 .filter(|i| !i.suppressed && i.severity == Severity::Warning)
2906 .count()
2907 }
2908}
2909
2910#[cfg(test)]
2911mod code_tests {
2912 use super::*;
2913 use std::collections::HashSet;
2914
2915 fn one_of_each() -> Vec<IssueKind> {
2921 let s = || String::new();
2922 vec![
2923 IssueKind::InvalidScope { in_class: false },
2924 IssueKind::NonStaticSelfCall {
2925 class: s(),
2926 method: s(),
2927 },
2928 IssueKind::DirectConstructorCall { class: s() },
2929 IssueKind::UndefinedVariable { name: s() },
2930 IssueKind::UndefinedFunction { name: s() },
2931 IssueKind::UndefinedMethod {
2932 class: s(),
2933 method: s(),
2934 },
2935 IssueKind::PossiblyUndefinedMethod {
2936 class: s(),
2937 method: s(),
2938 },
2939 IssueKind::UndefinedClass { name: s() },
2940 IssueKind::NotAnInterface { name: s() },
2941 IssueKind::UndefinedProperty {
2942 class: s(),
2943 property: s(),
2944 },
2945 IssueKind::UndefinedConstant { name: s() },
2946 IssueKind::InaccessibleClassConstant {
2947 class: s(),
2948 constant: s(),
2949 },
2950 IssueKind::InaccessibleProperty {
2951 class: s(),
2952 property: s(),
2953 },
2954 IssueKind::PossiblyUndefinedVariable { name: s() },
2955 IssueKind::UndefinedTrait { name: s() },
2956 IssueKind::TraitConstantAccessedDirectly {
2957 trait_name: s(),
2958 constant: s(),
2959 },
2960 IssueKind::UndefinedTraitAliasMethod {
2961 trait_name: Some(s()),
2962 method: s(),
2963 },
2964 IssueKind::ParentNotFound,
2965 IssueKind::NullArgument {
2966 param: s(),
2967 fn_name: s(),
2968 },
2969 IssueKind::NullPropertyFetch { property: s() },
2970 IssueKind::NullMethodCall { method: s() },
2971 IssueKind::NullArrayAccess,
2972 IssueKind::PossiblyNullArgument {
2973 param: s(),
2974 fn_name: s(),
2975 },
2976 IssueKind::PossiblyInvalidArgument {
2977 param: s(),
2978 fn_name: s(),
2979 expected: s(),
2980 actual: s(),
2981 },
2982 IssueKind::PossiblyNullPropertyFetch { property: s() },
2983 IssueKind::PossiblyNullMethodCall { method: s() },
2984 IssueKind::PossiblyNullArrayAccess,
2985 IssueKind::NullableReturnStatement {
2986 expected: s(),
2987 actual: s(),
2988 },
2989 IssueKind::InvalidReturnType {
2990 expected: s(),
2991 actual: s(),
2992 },
2993 IssueKind::InvalidArgument {
2994 param: s(),
2995 fn_name: s(),
2996 expected: s(),
2997 actual: s(),
2998 },
2999 IssueKind::TooFewArguments {
3000 fn_name: s(),
3001 expected: 0,
3002 actual: 0,
3003 },
3004 IssueKind::TooManyArguments {
3005 fn_name: s(),
3006 expected: 0,
3007 actual: 0,
3008 },
3009 IssueKind::InvalidNamedArgument {
3010 fn_name: s(),
3011 name: s(),
3012 overwrites: false,
3013 },
3014 IssueKind::InvalidNamedArguments { fn_name: s() },
3015 IssueKind::InvalidPassByReference {
3016 fn_name: s(),
3017 param: s(),
3018 },
3019 IssueKind::InvalidPropertyFetch { ty: s() },
3020 IssueKind::InvalidMethodCall {
3021 method: s(),
3022 ty: s(),
3023 },
3024 IssueKind::InvalidMemberName {
3025 member: s(),
3026 ty: s(),
3027 },
3028 IssueKind::NativeResourceType { class: s() },
3029 IssueKind::InvalidUnpack { ty: s() },
3030 IssueKind::InvalidArrayAccess { ty: s() },
3031 IssueKind::PossiblyInvalidArrayAccess { ty: s() },
3032 IssueKind::InvalidArrayAssignment { ty: s() },
3033 IssueKind::InvalidPropertyAssignment {
3034 property: s(),
3035 expected: s(),
3036 actual: s(),
3037 },
3038 IssueKind::PossiblyNullPropertyAssignmentValue {
3039 property: s(),
3040 expected: s(),
3041 actual: s(),
3042 },
3043 IssueKind::PossiblyFalsePropertyAssignmentValue {
3044 property: s(),
3045 expected: s(),
3046 actual: s(),
3047 },
3048 IssueKind::PossiblyInvalidPropertyAssignmentValue {
3049 property: s(),
3050 expected: s(),
3051 actual: s(),
3052 },
3053 IssueKind::InvalidCast { from: s(), to: s() },
3054 IssueKind::InvalidStaticInvocation {
3055 class: s(),
3056 method: s(),
3057 },
3058 IssueKind::InvalidOperand {
3059 op: s(),
3060 left: s(),
3061 right: s(),
3062 },
3063 IssueKind::PossiblyInvalidOperand {
3064 op: s(),
3065 left: s(),
3066 right: s(),
3067 },
3068 IssueKind::PossiblyNullOperand { op: s(), ty: s() },
3069 IssueKind::DivisionByZero { op: s() },
3070 IssueKind::RawObjectIteration { ty: s() },
3071 IssueKind::PossiblyRawObjectIteration { ty: s() },
3072 IssueKind::InvalidGeneratorIteration { ty: s(), send: s() },
3073 IssueKind::MismatchingDocblockReturnType {
3074 declared: s(),
3075 inferred: s(),
3076 },
3077 IssueKind::MismatchingDocblockParamType {
3078 param: s(),
3079 declared: s(),
3080 inferred: s(),
3081 },
3082 IssueKind::TypeCheckMismatch {
3083 var: s(),
3084 expected: s(),
3085 actual: s(),
3086 },
3087 IssueKind::Trace {
3088 variable: s(),
3089 type_info: s(),
3090 },
3091 IssueKind::InvalidArrayOffset {
3092 expected: s(),
3093 actual: s(),
3094 },
3095 IssueKind::NonExistentArrayOffset { key: s() },
3096 IssueKind::PossiblyInvalidArrayOffset {
3097 expected: s(),
3098 actual: s(),
3099 },
3100 IssueKind::DuplicateArrayKey { key: s() },
3101 IssueKind::RedundantCondition {
3102 always_true: true,
3103 unreachable: None,
3104 },
3105 IssueKind::RedundantCast { from: s(), to: s() },
3106 IssueKind::UnnecessaryVarAnnotation { var: s() },
3107 IssueKind::TypeDoesNotContainType {
3108 left: s(),
3109 right: s(),
3110 },
3111 IssueKind::UnusedVariable { name: s() },
3112 IssueKind::UnusedParam { name: s() },
3113 IssueKind::UnreachableCode,
3114 IssueKind::UnhandledMatchCondition { detail: s() },
3115 IssueKind::UnusedMethod {
3116 class: s(),
3117 method: s(),
3118 },
3119 IssueKind::UnusedProperty {
3120 class: s(),
3121 property: s(),
3122 },
3123 IssueKind::UnusedFunction { name: s() },
3124 IssueKind::UnusedForeachValue { name: s() },
3125 IssueKind::UnusedClass { class: s() },
3126 IssueKind::UnusedConstant {
3127 class: s(),
3128 constant: s(),
3129 },
3130 IssueKind::UnusedSuppress { kind: s() },
3131 IssueKind::ArgumentTypeCoercion {
3132 param: s(),
3133 fn_name: s(),
3134 expected: s(),
3135 actual: s(),
3136 },
3137 IssueKind::PropertyTypeCoercion {
3138 property: s(),
3139 expected: s(),
3140 actual: s(),
3141 },
3142 IssueKind::ImpurePropertyAssignment { property: s() },
3143 IssueKind::ImpureMethodCall { method: s() },
3144 IssueKind::ImpureGlobalVariable { variable: s() },
3145 IssueKind::ImpureStaticVariable { variable: s() },
3146 IssueKind::ImpureByRefAssignment { variable: s() },
3147 IssueKind::ImpureStaticPropertyAssignment {
3148 class: s(),
3149 property: s(),
3150 },
3151 IssueKind::ImpureStaticPropertyAccess {
3152 class: s(),
3153 property: s(),
3154 },
3155 IssueKind::ImpureFunctionCall { fn_name: s() },
3156 IssueKind::ImmutablePropertyModification {
3157 receiver: s(),
3158 property: s(),
3159 },
3160 IssueKind::ReadonlyPropertyAssignment {
3161 class: s(),
3162 property: s(),
3163 unset: false,
3164 },
3165 IssueKind::ReadonlyPropertyAlreadyInitialized {
3166 class: s(),
3167 property: s(),
3168 },
3169 IssueKind::UnimplementedAbstractMethod {
3170 class: s(),
3171 method: s(),
3172 },
3173 IssueKind::UnimplementedInterfaceMethod {
3174 class: s(),
3175 interface: s(),
3176 method: s(),
3177 },
3178 IssueKind::MethodSignatureMismatch {
3179 class: s(),
3180 method: s(),
3181 detail: s(),
3182 },
3183 IssueKind::OverriddenMethodAccess {
3184 class: s(),
3185 method: s(),
3186 parent: s(),
3187 visibility: s(),
3188 },
3189 IssueKind::OverriddenPropertyAccess {
3190 class: s(),
3191 property: s(),
3192 parent: s(),
3193 visibility: s(),
3194 },
3195 IssueKind::PropertyTypeRedeclarationMismatch {
3196 class: s(),
3197 property: s(),
3198 parent: s(),
3199 expected: s(),
3200 covariant: false,
3201 before_php85: false,
3202 },
3203 IssueKind::NonInvariantDocblockPropertyType {
3204 class: s(),
3205 property: s(),
3206 parent: s(),
3207 expected: s(),
3208 actual: s(),
3209 },
3210 IssueKind::ReadonlyPropertyRedeclarationMismatch {
3211 parent_class: s(),
3212 class: s(),
3213 property: s(),
3214 parent_readonly: true,
3215 },
3216 IssueKind::StaticPropertyRedeclarationMismatch {
3217 parent_class: s(),
3218 class: s(),
3219 property: s(),
3220 parent_static: true,
3221 },
3222 IssueKind::ReadonlyClassExtendsMismatch {
3223 parent: s(),
3224 child: s(),
3225 parent_readonly: true,
3226 },
3227 IssueKind::InvalidReadonlyPropertyDeclaration {
3228 class: s(),
3229 property: s(),
3230 },
3231 IssueKind::BackedEnumCaseTypeMismatch {
3232 enum_name: s(),
3233 case_name: s(),
3234 expected: s(),
3235 actual: s(),
3236 },
3237 IssueKind::DuplicateEnumCaseValue {
3238 enum_name: s(),
3239 first_case: s(),
3240 case_name: s(),
3241 },
3242 IssueKind::InvalidExtendClass {
3243 parent: s(),
3244 child: s(),
3245 },
3246 IssueKind::FinalMethodOverridden {
3247 class: s(),
3248 method: s(),
3249 parent: s(),
3250 },
3251 IssueKind::AbstractInstantiation { class: s() },
3252 IssueKind::AbstractMethodCall {
3253 class: s(),
3254 method: s(),
3255 },
3256 IssueKind::InterfaceInstantiation { class: s() },
3257 IssueKind::EnumInstantiation { class: s() },
3258 IssueKind::TraitInstantiation { class: s() },
3259 IssueKind::InvalidDynamicProperty {
3260 class: s(),
3261 property: s(),
3262 },
3263 IssueKind::DynamicPropertyCreation {
3264 class: s(),
3265 property: s(),
3266 },
3267 IssueKind::InvalidOverride {
3268 class: s(),
3269 member: s(),
3270 },
3271 IssueKind::CircularInheritance { class: s() },
3272 IssueKind::TaintedInput { sink: s() },
3273 IssueKind::TaintedHtml,
3274 IssueKind::TaintedSql,
3275 IssueKind::TaintedShell,
3276 IssueKind::TaintedLlmPrompt,
3277 IssueKind::TaintedHeader,
3278 IssueKind::TaintedCookie,
3279 IssueKind::TaintedSsrf,
3280 IssueKind::TaintedLdap,
3281 IssueKind::TaintedXpath,
3282 IssueKind::TaintedCallable,
3283 IssueKind::TaintedFile,
3284 IssueKind::TaintedInclude,
3285 IssueKind::TaintedEval,
3286 IssueKind::TaintedUnserialize,
3287 IssueKind::InvalidTemplateParam {
3288 name: s(),
3289 expected_bound: s(),
3290 actual: s(),
3291 },
3292 IssueKind::ShadowedTemplateParam { name: s() },
3293 IssueKind::DeprecatedCall {
3294 name: s(),
3295 message: None,
3296 },
3297 IssueKind::DeprecatedProperty {
3298 class: s(),
3299 property: s(),
3300 message: None,
3301 },
3302 IssueKind::DeprecatedConstant {
3303 class: s(),
3304 constant: s(),
3305 message: None,
3306 },
3307 IssueKind::OptionalParameterBeforeRequired { message: s() },
3308 IssueKind::ImplicitlyNullableParameter { message: s() },
3309 IssueKind::DeprecatedInterface {
3310 name: s(),
3311 message: None,
3312 },
3313 IssueKind::DeprecatedTrait {
3314 name: s(),
3315 message: None,
3316 },
3317 IssueKind::DeprecatedMethodCall {
3318 class: s(),
3319 method: s(),
3320 message: None,
3321 },
3322 IssueKind::DeprecatedMethod {
3323 class: s(),
3324 method: s(),
3325 message: None,
3326 },
3327 IssueKind::DeprecatedClass {
3328 name: s(),
3329 message: None,
3330 },
3331 IssueKind::InternalMethod {
3332 class: s(),
3333 method: s(),
3334 },
3335 IssueKind::MissingReturnType { fn_name: s() },
3336 IssueKind::MissingClosureReturnType,
3337 IssueKind::MissingParamType {
3338 fn_name: s(),
3339 param: s(),
3340 },
3341 IssueKind::MissingPropertyType {
3342 class: s(),
3343 property: s(),
3344 },
3345 IssueKind::MissingThrowsDocblock { class: s() },
3346 IssueKind::InvalidDocblock { message: s() },
3347 IssueKind::UndefinedThrowsDocblock { name: s() },
3348 IssueKind::InvalidDocblockType { message: s() },
3349 IssueKind::MixedArgument {
3350 param: s(),
3351 fn_name: s(),
3352 },
3353 IssueKind::MixedAssignment { var: s() },
3354 IssueKind::MixedMethodCall { method: s() },
3355 IssueKind::UnsupportedReferenceUsage,
3356 IssueKind::NoInterfaceProperties { property: s() },
3357 IssueKind::UndefinedDocblockClass { name: s() },
3358 IssueKind::MissingConstructor { class: s() },
3359 IssueKind::PropertyPossiblyUninitialized {
3360 class: s(),
3361 property: s(),
3362 },
3363 IssueKind::MixedFunctionCall,
3364 IssueKind::MixedReturnStatement { declared: s() },
3365 IssueKind::MixedPropertyFetch { property: s() },
3366 IssueKind::MixedPropertyAssignment { property: s() },
3367 IssueKind::MixedArrayAccess,
3368 IssueKind::MixedArrayOffset,
3369 IssueKind::MixedClone,
3370 IssueKind::InvalidClone {
3371 ty: s(),
3372 reason: CloneFailure::NonObject,
3373 },
3374 IssueKind::PossiblyInvalidClone { ty: s() },
3375 IssueKind::InvalidToString { class: s() },
3376 IssueKind::InvalidTraitUse {
3377 trait_name: s(),
3378 reason: s(),
3379 },
3380 IssueKind::ParseError {
3381 message: s(),
3382 code: s(),
3383 },
3384 IssueKind::CompileError {
3385 message: s(),
3386 code: s(),
3387 },
3388 IssueKind::InvalidThrow { ty: s() },
3389 IssueKind::InvalidCatch { ty: s() },
3390 IssueKind::UnreachableCatch {
3391 ty: s(),
3392 shadowed_by: s(),
3393 },
3394 IssueKind::ImplicitToStringCast { class: s() },
3395 IssueKind::ImplicitFloatToIntCast { from: s() },
3396 IssueKind::WrongCaseFunction {
3397 used: s(),
3398 canonical: s(),
3399 },
3400 IssueKind::WrongCaseMethod {
3401 class: s(),
3402 used: s(),
3403 canonical: s(),
3404 },
3405 IssueKind::WrongCaseClass {
3406 used: s(),
3407 canonical: s(),
3408 },
3409 IssueKind::InvalidAttribute { message: s() },
3410 IssueKind::UndefinedAttributeClass { name: s() },
3411 IssueKind::ForbiddenCode { message: s() },
3412 IssueKind::DuplicateClass { name: s() },
3413 IssueKind::DuplicateInterface { name: s() },
3414 IssueKind::DuplicateTrait { name: s() },
3415 IssueKind::DuplicateEnum { name: s() },
3416 IssueKind::DuplicateFunction { name: s() },
3417 IssueKind::UseStatementHasNoEffect { name: s() },
3418 IssueKind::PrivateFinalMethod {
3419 class: s(),
3420 method: s(),
3421 },
3422 IssueKind::NonPublicMagicMethod {
3423 class: s(),
3424 method: s(),
3425 },
3426 IssueKind::NoDiscardReturnIgnored {
3427 callee: s(),
3428 message: None,
3429 },
3430 ]
3431 }
3432
3433 #[test]
3434 fn codes_have_expected_shape() {
3435 for kind in one_of_each() {
3436 let code = kind.code();
3437 assert!(
3438 code.len() == 7
3439 && code.starts_with("MIR")
3440 && code[3..].chars().all(|c| c.is_ascii_digit()),
3441 "code {code:?} for {} does not match MIR####",
3442 kind.name(),
3443 );
3444 }
3445 }
3446
3447 #[test]
3448 fn codes_are_unique() {
3449 let kinds = one_of_each();
3450 let mut seen: HashSet<&'static str> = HashSet::new();
3451 for kind in &kinds {
3452 assert!(
3453 seen.insert(kind.code()),
3454 "duplicate code {} (variant {})",
3455 kind.code(),
3456 kind.name(),
3457 );
3458 }
3459 }
3460
3461 #[test]
3462 fn default_severity_for_code_round_trips() {
3463 for kind in one_of_each() {
3464 let code = kind.code();
3465 assert_eq!(
3466 IssueKind::default_severity_for_code(code),
3467 Some(kind.default_severity()),
3468 "severity mismatch for {code} (variant {})",
3469 kind.name(),
3470 );
3471 }
3472 }
3473
3474 #[test]
3475 fn default_severity_for_code_unknown_returns_none() {
3476 assert_eq!(IssueKind::default_severity_for_code("MIR9999"), None);
3477 assert_eq!(IssueKind::default_severity_for_code(""), None);
3478 assert_eq!(IssueKind::default_severity_for_code("mir0001"), None);
3479 }
3480
3481 #[test]
3484 fn one_of_each_has_every_variant() {
3485 assert_eq!(one_of_each().len(), 193);
3488 }
3489}