From 9130ee26147efafb8e27581348f55bea719fc7e3 Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Thu, 29 Dec 2022 18:47:40 +0100 Subject: [PATCH] fixes return type issues of methods reported for the wrong file fixes return type issues of methods reported for the wrong file Fix #8457 See https://github.com/vimeo/psalm/pull/8503 which fixed this issue for functions --- src/Psalm/Internal/Codebase/Methods.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Psalm/Internal/Codebase/Methods.php b/src/Psalm/Internal/Codebase/Methods.php index 37631e603d9..cea74876f2c 100644 --- a/src/Psalm/Internal/Codebase/Methods.php +++ b/src/Psalm/Internal/Codebase/Methods.php @@ -920,6 +920,12 @@ public function getMethodReturnTypeLocation( $storage = $this->getStorage($method_id); + // if function exists in stubs and in analyzed code + // use the return type location of the analyzed code instead of the stubbed location + if ($storage->stubbed) { + return null; + } + if (!$storage->return_type_location) { $overridden_method_ids = $this->getOverriddenMethodIds($method_id);