|
23 | 23 | use Psalm\Issue\LessSpecificImplementedReturnType;
|
24 | 24 | use Psalm\Issue\MethodSignatureMismatch;
|
25 | 25 | use Psalm\Issue\MethodSignatureMustProvideReturnType;
|
| 26 | +use Psalm\Issue\MismatchingDocblockParamType; |
| 27 | +use Psalm\Issue\MismatchingDocblockReturnType; |
26 | 28 | use Psalm\Issue\MissingImmutableAnnotation;
|
27 | 29 | use Psalm\Issue\MoreSpecificImplementedParamType;
|
28 | 30 | use Psalm\Issue\OverriddenMethodAccess;
|
@@ -254,6 +256,9 @@ public static function comparePseudoMethods(
|
254 | 256 | );
|
255 | 257 |
|
256 | 258 | $overridden_method_ids = $codebase->methods->getOverriddenMethodIds($pseudo_method_id);
|
| 259 | + if (isset($class_storage->methods[$pseudo_method_id->method_name])) { |
| 260 | + $overridden_method_ids[$class_storage->name] = $pseudo_method_id; |
| 261 | + } |
257 | 262 |
|
258 | 263 | if ($overridden_method_ids
|
259 | 264 | && $pseudo_method_name !== '__construct'
|
@@ -871,6 +876,18 @@ private static function compareMethodDocblockParams(
|
871 | 876 | ),
|
872 | 877 | $suppressed_issues + $implementer_classlike_storage->suppressed_issues,
|
873 | 878 | );
|
| 879 | + } elseif ($guide_class_name == $implementer_called_class_name) { |
| 880 | + IssueBuffer::maybeAdd( |
| 881 | + new MismatchingDocblockParamType( |
| 882 | + 'Argument ' . ($i + 1) . ' of ' . $cased_implementer_method_id |
| 883 | + . ' has wrong type \'' . |
| 884 | + $implementer_method_storage_param_type->getId() . '\' in @method annotation, expecting \'' . |
| 885 | + $guide_method_storage_param_type->getId() . '\'', |
| 886 | + $implementer_method_storage->params[$i]->location |
| 887 | + ?: $code_location, |
| 888 | + ), |
| 889 | + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, |
| 890 | + ); |
874 | 891 | } else {
|
875 | 892 | IssueBuffer::maybeAdd(
|
876 | 893 | new ImplementedParamTypeMismatch(
|
@@ -1092,6 +1109,17 @@ private static function compareMethodDocblockReturnTypes(
|
1092 | 1109 | ),
|
1093 | 1110 | $suppressed_issues + $implementer_classlike_storage->suppressed_issues,
|
1094 | 1111 | );
|
| 1112 | + } elseif ($guide_class_name == $implementer_called_class_name) { |
| 1113 | + IssueBuffer::maybeAdd( |
| 1114 | + new MismatchingDocblockReturnType( |
| 1115 | + 'The inherited return type \'' . $guide_method_storage_return_type->getId() |
| 1116 | + . '\' for ' . $cased_guide_method_id . ' is different to the corresponding ' |
| 1117 | + . '@method annotation \'' . $implementer_method_storage_return_type->getId() . '\'', |
| 1118 | + $implementer_method_storage->return_type_location |
| 1119 | + ?: $code_location, |
| 1120 | + ), |
| 1121 | + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, |
| 1122 | + ); |
1095 | 1123 | } else {
|
1096 | 1124 | IssueBuffer::maybeAdd(
|
1097 | 1125 | new ImplementedReturnTypeMismatch(
|
|
0 commit comments