1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Ignore annotated magic properties with usage static gap

In PHP is not exists methods for implementation magic static properties.
So, these magic static properties must not be presented.
This commit is contained in:
Ivan Sidorov 2023-11-14 10:47:25 +00:00
parent 1cfc343c43
commit 715f6f51e1
2 changed files with 25 additions and 38 deletions

View File

@ -1918,35 +1918,35 @@ final class Codebase
}
}
$pseudo_property_types = [];
foreach ($class_storage->pseudo_property_get_types as $property_name => $type) {
$pseudo_property_types[$property_name] = new CompletionItem(
str_replace('$', '', $property_name),
CompletionItemKind::PROPERTY,
$type->__toString(),
null,
'1', //sort text
str_replace('$', '', $property_name),
($gap === '::' ? '$' : '') .
if ($gap === '->') {
$pseudo_property_types = [];
foreach ($class_storage->pseudo_property_get_types as $property_name => $type) {
$pseudo_property_types[$property_name] = new CompletionItem(
str_replace('$', '', $property_name),
);
}
foreach ($class_storage->pseudo_property_set_types as $property_name => $type) {
$pseudo_property_types[$property_name] = new CompletionItem(
str_replace('$', '', $property_name),
CompletionItemKind::PROPERTY,
$type->__toString(),
null,
'1',
str_replace('$', '', $property_name),
($gap === '::' ? '$' : '') .
CompletionItemKind::PROPERTY,
$type->__toString(),
null,
'1', //sort text
str_replace('$', '', $property_name),
);
str_replace('$', '', $property_name),
);
}
foreach ($class_storage->pseudo_property_set_types as $property_name => $type) {
$pseudo_property_types[$property_name] = new CompletionItem(
str_replace('$', '', $property_name),
CompletionItemKind::PROPERTY,
$type->__toString(),
null,
'1',
str_replace('$', '', $property_name),
str_replace('$', '', $property_name),
);
}
$completion_items = [...$completion_items, ...array_values($pseudo_property_types)];
}
$completion_items = [...$completion_items, ...array_values($pseudo_property_types)];
foreach ($class_storage->declaring_property_ids as $property_name => $declaring_class) {
$property_storage = $this->properties->getStorage(
$declaring_class . '::$' . $property_name,

View File

@ -141,8 +141,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase
'privateStaticMethod',
],
'::' => [
'magicObjProp1',
'magicObjProp2',
'magicStaticMethod',
'publicStaticProp',
@ -221,8 +219,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase
'privateStaticMethod',
],
'::' => [
'magicObjProp1',
'magicObjProp2',
'magicStaticMethod',
'publicStaticProp',
@ -293,9 +289,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase
'privateObjProp',
],
'::' => [
'magicObjProp1',
'magicObjProp2',
'publicStaticProp',
'protectedStaticProp',
'privateStaticProp',
@ -360,9 +353,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase
'privateObjProp',
],
'::' => [
'magicObjProp1',
'magicObjProp2',
'publicStaticProp',
'protectedStaticProp',
'privateStaticProp',
@ -423,9 +413,6 @@ final class MethodGetCompletionItemsForClassishThingTest extends TestCase
'protectedObjProp',
],
'::' => [
'magicObjProp1',
'magicObjProp2',
'publicStaticProp',
'protectedStaticProp',
],