Skip to content

Commit

Permalink
Fix reference generation from methods in --diff mode
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 6, 2020
1 parent a2a5071 commit 10b807b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ private static function analyzeAtomicCall(
$method_id,
$context->calling_function_id,
$codebase->collect_references ? new CodeLocation($source, $stmt->name) : null,
null,
$statements_analyzer,
$statements_analyzer->getFilePath()
)
|| !MethodAnalyzer::isMethodVisible(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public static function analyze(
$method_id,
$context->calling_function_id,
$context->collect_references ? new CodeLocation($statements_analyzer->getSource(), $stmt) : null,
null,
$statements_analyzer,
$statements_analyzer->getFilePath()
)) {
if ($codebase->store_node_types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public static function analyze(
$method_id,
$context->calling_function_id,
$codebase->collect_references ? new CodeLocation($source, $stmt->name) : null,
null,
$statements_analyzer,
$statements_analyzer->getFilePath()
)
|| !MethodAnalyzer::isMethodVisible(
Expand All @@ -443,7 +443,7 @@ public static function analyze(
$callstatic_id,
$context->calling_function_id,
$codebase->collect_references ? new CodeLocation($source, $stmt->name) : null,
null,
$statements_analyzer,
$statements_analyzer->getFilePath()
)) {
if (isset($class_storage->pseudo_static_methods[$method_name_lc])) {
Expand Down
28 changes: 14 additions & 14 deletions src/Psalm/Internal/Codebase/Methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function methodExists(
$calling_function_id = null,
CodeLocation $code_location = null,
StatementsSource $source = null,
string $file_path = null
string $source_file_path = null
) {
$fq_class_name = $method_id->fq_class_name;
$method_name = $method_id->method_name;
Expand Down Expand Up @@ -126,7 +126,7 @@ public function methodExists(
return false;
}

if ($source && $fq_class_name !== $source->getFQCLN()) {
if ($source && $fq_class_name !== strtolower($source->getFQCLN())) {
$this->file_reference_provider->addFileReferenceToClass(
$source->getFilePath(),
$fq_class_name
Expand All @@ -150,9 +150,9 @@ public function methodExists(
$calling_function_id,
$potential_id
);
} elseif ($file_path) {
} elseif ($source_file_path) {
$this->file_reference_provider->addFileReferenceToClassMember(
$file_path,
$source_file_path,
$potential_id
);
}
Expand All @@ -163,9 +163,9 @@ public function methodExists(
$calling_function_id,
strtolower((string) $declaring_method_id)
);
} elseif ($file_path) {
} elseif ($source_file_path) {
$this->file_reference_provider->addFileReferenceToClassMember(
$file_path,
$source_file_path,
strtolower((string) $declaring_method_id)
);
}
Expand Down Expand Up @@ -193,9 +193,9 @@ public function methodExists(
$calling_function_id,
$interface_method_id_lc
);
} elseif ($file_path) {
} elseif ($source_file_path) {
$this->file_reference_provider->addFileReferenceToClassMember(
$file_path,
$source_file_path,
$interface_method_id_lc
);
}
Expand Down Expand Up @@ -223,9 +223,9 @@ public function methodExists(
$calling_function_id,
strtolower((string) $overridden_method_id)
);
} elseif ($file_path) {
} elseif ($source_file_path) {
$this->file_reference_provider->addFileReferenceToClassMember(
$file_path,
$source_file_path,
strtolower((string) $overridden_method_id)
);
}
Expand Down Expand Up @@ -261,9 +261,9 @@ public function methodExists(
$calling_function_id,
$potential_id
);
} elseif ($file_path) {
} elseif ($source_file_path) {
$this->file_reference_provider->addFileReferenceToMissingClassMember(
$file_path,
$source_file_path,
$potential_id
);
}
Expand All @@ -275,9 +275,9 @@ public function methodExists(
$calling_function_id,
strtolower((string) $method_id)
);
} elseif ($file_path) {
} elseif ($source_file_path) {
$this->file_reference_provider->addFileReferenceToMissingClassMember(
$file_path,
$source_file_path,
strtolower((string) $method_id)
);
}
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Internal/Provider/FileReferenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function ($file_name) {
}

/**
* @param lowercase-string $fq_class_name_lc
* @return void
*/
public function addFileReferenceToClass(string $source_file, string $fq_class_name_lc)
Expand Down

0 comments on commit 10b807b

Please sign in to comment.