Skip to content

Commit

Permalink
Invalidate cached methods when referenced files are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
tscni committed Jun 19, 2023
1 parent 474f887 commit 1161edf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Psalm/Internal/Codebase/Analyzer.php
Expand Up @@ -687,6 +687,16 @@ public function loadCachedResults(ProjectAnalyzer $project_analyzer): void
}
}

// This could be optimized by storing method references to files
foreach ($file_reference_provider->getDeletedReferencedFiles() as $deleted_file) {
foreach ($file_reference_provider->getFilesReferencingFile($deleted_file) as $file_referencing_deleted) {
$methods_referencing_deleted = $this->analyzed_methods[$file_referencing_deleted] ?? [];
foreach ($methods_referencing_deleted as $method_referencing_deleted => $_) {
$newly_invalidated_methods[$method_referencing_deleted] = true;
}
}
}

foreach ($newly_invalidated_methods as $method_id => $_) {
foreach ($method_references_to_class_members as $i => $_) {
unset($method_references_to_class_members[$i][$method_id]);
Expand Down

0 comments on commit 1161edf

Please sign in to comment.