diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php index e3a632692..62ff319f5 100644 --- a/src/Psalm/Internal/Analyzer/MethodComparator.php +++ b/src/Psalm/Internal/Analyzer/MethodComparator.php @@ -50,11 +50,13 @@ class MethodComparator bool $prevent_abstract_override = true, bool $prevent_method_signature_mismatch = true ): ?bool { + $implementer_method_id = new MethodIdentifier( + $implementer_classlike_storage->name, + strtolower($guide_method_storage->cased_name ?: '') + ); + $implementer_declaring_method_id = $codebase->methods->getDeclaringMethodId( - new MethodIdentifier( - $implementer_classlike_storage->name, - strtolower($guide_method_storage->cased_name ?: '') - ) + $implementer_method_id ); $cased_implementer_method_id = $implementer_classlike_storage->name . '::' @@ -62,6 +64,11 @@ class MethodComparator $cased_guide_method_id = $guide_classlike_storage->name . '::' . $guide_method_storage->cased_name; + $codebase->methods->file_reference_provider->addMethodReferenceToClassMember( + strtolower((string)($implementer_declaring_method_id ?: $implementer_method_id)), + strtolower($guide_classlike_storage->name . '::' . $guide_method_storage->cased_name) + ); + self::checkForObviousMethodMismatches( $guide_classlike_storage, $implementer_classlike_storage, diff --git a/tests/FileUpdates/ErrorAfterUpdateTest.php b/tests/FileUpdates/ErrorAfterUpdateTest.php index eb45e11fc..3c026671d 100644 --- a/tests/FileUpdates/ErrorAfterUpdateTest.php +++ b/tests/FileUpdates/ErrorAfterUpdateTest.php @@ -907,6 +907,43 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase ], 'error_message' => 'PropertyNotSetInConstructor', ], + 'invalidateChildMethodWhenSignatureChanges' => [ + 'file_stages' => [ + [ + getcwd() . DIRECTORY_SEPARATOR . 'A.php' => ' ' 'MethodSignatureMismatch', + ], ]; } }