Skip to content

Commit

Permalink
Fixing a crash if a method or property does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
issidorov committed Nov 17, 2023
1 parent ecdd732 commit 87e4c2e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,11 @@ public function getCompletionItemsForClassishThing(

$method_storages = [];
foreach ($class_storage->declaring_method_ids as $declaring_method_id) {
$method_storages[] = $this->methods->getStorage($declaring_method_id);
try {
$method_storages[] = $this->methods->getStorage($declaring_method_id);
} catch (UnexpectedValueException $e) {
error_log($e->getMessage());
}
}
if ($gap === '->') {
$method_storages += $class_storage->pseudo_methods;
Expand Down Expand Up @@ -1970,9 +1974,14 @@ public function getCompletionItemsForClassishThing(
}

foreach ($class_storage->declaring_property_ids as $property_name => $declaring_class) {
$property_storage = $this->properties->getStorage(
$declaring_class . '::$' . $property_name,
);
try {
$property_storage = $this->properties->getStorage(
$declaring_class . '::$' . $property_name,
);
} catch (UnexpectedValueException $e) {
error_log($e->getMessage());
continue;
}

if (!in_array($property_storage->visibility, $allow_visibilities)) {
continue;
Expand Down

0 comments on commit 87e4c2e

Please sign in to comment.