Skip to content

Commit

Permalink
Make invalidation more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jul 3, 2020
1 parent 5da2995 commit 7c7ebd0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Psalm/Internal/Codebase/Methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public function methodExists(
return false;
}

$source_file_path = $source ? $source->getFilePath() : $source_file_path;

$calling_class_name = $source ? $source->getFQCLN() : null;

if (!$calling_class_name && $calling_method_id) {
$calling_class_name = explode('::', $calling_method_id)[0];
}

if (isset($class_storage->declaring_method_ids[$method_name])) {
$declaring_method_id = $class_storage->declaring_method_ids[$method_name];

Expand All @@ -128,15 +136,15 @@ public function methodExists(

$declaring_fq_class_name = strtolower($declaring_method_id->fq_class_name);

if ($source && $declaring_fq_class_name !== strtolower((string) $source->getFQCLN())) {
if ($declaring_fq_class_name !== strtolower((string) $calling_class_name)) {
if ($calling_method_id) {
$this->file_reference_provider->addMethodReferenceToClass(
$calling_method_id,
$declaring_fq_class_name
);
} else {
} elseif ($source_file_path) {
$this->file_reference_provider->addNonMethodReferenceToClass(
$source->getFilePath(),
$source_file_path,
$declaring_fq_class_name
);
}
Expand Down Expand Up @@ -237,15 +245,15 @@ public function methodExists(
return true;
}

if ($source && $fq_class_name !== strtolower((string) $source->getFQCLN())) {
if ($source_file_path && $fq_class_name !== strtolower((string) $calling_class_name)) {
if ($calling_method_id) {
$this->file_reference_provider->addMethodReferenceToClass(
$calling_method_id,
$fq_class_name
);
} else {
$this->file_reference_provider->addNonMethodReferenceToClass(
$source->getFilePath(),
$source_file_path,
$fq_class_name
);
}
Expand Down

0 comments on commit 7c7ebd0

Please sign in to comment.