diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php index a84014d8ab9..d7e566754a2 100644 --- a/src/Psalm/Codebase.php +++ b/src/Psalm/Codebase.php @@ -1593,11 +1593,22 @@ public function getCompletionItemsForClassishThing( error_log($e->getMessage()); } } + if ($gap === '->') { + $method_storages += $class_storage->pseudo_methods; + } + if ($gap === '::') { + $method_storages += $class_storage->pseudo_static_methods; + } + $had = []; foreach ($method_storages as $method_storage) { if (!in_array($method_storage->visibility, $allow_visibilities)) { continue; } + if (array_key_exists($method_storage->cased_name, $had)) { + continue; + } + $had[$method_storage->cased_name] = true; if ($method_storage->is_static || $gap === '->') { $completion_item = new CompletionItem( $method_storage->cased_name, diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php index 64eb5550bdb..bc0f61bb169 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php @@ -641,9 +641,6 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool if (!isset($storage->overridden_method_ids[$lc_method_name])) { $storage->overridden_method_ids[$lc_method_name] = []; } - if (!isset($storage->declaring_method_ids[$lc_method_name])) { - $storage->declaring_method_ids[$lc_method_name] = $method_identifier; - } $storage->declaring_pseudo_method_ids[$lc_method_name] = $method_identifier; } diff --git a/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php b/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php index ea48ce571cb..704074560dc 100644 --- a/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php +++ b/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php @@ -126,7 +126,6 @@ private static function privateStaticMethod() {} 'magicObjProp2', 'magicObjMethod', - 'magicStaticMethod', 'publicObjProp', 'protectedObjProp', @@ -202,8 +201,6 @@ private static function privateStaticMethod() {} 'magicObjMethod', - 'magicStaticMethod', - 'publicObjProp', 'protectedObjProp', 'privateObjProp', @@ -442,8 +439,8 @@ class A extends C { 'magicObjProp1', 'magicObjProp2', - 'magicStaticMethod', 'magicObjMethod', + 'magicStaticMethod', 'publicObjProp', 'protectedObjProp', @@ -548,7 +545,6 @@ class A { 'magicObjProp1', 'magicObjProp2', 'magicObjMethod', - 'magicStaticMethod', 'publicObjProp',