From d533bb8c2e91654b6de0e4ee2bad0401ef0facd3 Mon Sep 17 00:00:00 2001 From: Ivan Sidorov Date: Wed, 15 Nov 2023 11:09:54 +0000 Subject: [PATCH] Ignore annotated magic static methods with usage object gap Magic methods annotated by methods `__call` and `__callStatic`. Magic static methods implemented in `__callStatic` are not required implementation in `__call'. --- src/Psalm/Codebase.php | 16 +++++++++------- ...hodGetCompletionItemsForClassishThingTest.php | 2 -- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php index 4865129ef..90af927a3 100644 --- a/src/Psalm/Codebase.php +++ b/src/Psalm/Codebase.php @@ -69,7 +69,6 @@ use ReflectionType; use UnexpectedValueException; use function array_combine; -use function array_merge; use function array_pop; use function array_reverse; use function array_values; @@ -1884,12 +1883,15 @@ final class Codebase try { $class_storage = $this->classlike_storage_provider->get($atomic_type->value); - $methods = array_merge( - $class_storage->methods, - $class_storage->pseudo_methods, - $class_storage->pseudo_static_methods, - ); - foreach ($methods as $method_storage) { + $method_storages = [...$class_storage->methods]; + if ($gap === '->') { + $method_storages += $class_storage->pseudo_methods; + } + if ($gap === '::') { + $method_storages += $class_storage->pseudo_static_methods; + } + + foreach ($method_storages as $method_storage) { if ($method_storage->is_static || $gap === '->') { $completion_item = new CompletionItem( $method_storage->cased_name, diff --git a/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php b/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php index 3a8f56c74..3dac881b8 100644 --- a/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php +++ b/tests/Internal/Codebase/MethodGetCompletionItemsForClassishThingTest.php @@ -126,7 +126,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase 'magicObjProp2', 'magicObjMethod', - 'magicStaticMethod', 'publicObjProp', 'protectedObjProp', @@ -201,7 +200,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase 'magicObjProp2', 'magicObjMethod', - 'magicStaticMethod', 'publicObjProp', 'protectedObjProp',