From 6381c802076769a3079f25e964bd43248a46a2ac 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] Update Methods.php 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..4dcb463b202 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);