1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Make invalidation more robust

This commit is contained in:
Brown 2020-07-03 12:59:07 -04:00
parent 5da29955ee
commit 7c7ebd068f

View File

@ -119,6 +119,14 @@ class Methods
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];
@ -128,15 +136,15 @@ class Methods
$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
);
}
@ -237,7 +245,7 @@ class Methods
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,
@ -245,7 +253,7 @@ class Methods
);
} else {
$this->file_reference_provider->addNonMethodReferenceToClass(
$source->getFilePath(),
$source_file_path,
$fq_class_name
);
}