Skip to content

Commit

Permalink
Improve accuracy of diff generation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 6, 2020
1 parent f3d7ed6 commit 766effb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,10 @@ private static function analyzeAtomicCall(
$method_id,
$context->calling_function_id,
$codebase->collect_references ? new CodeLocation($source, $stmt->name) : null,
$statements_analyzer,
!$context->collect_initializations
&& !$context->collect_mutations
? $statements_analyzer
: null,
$statements_analyzer->getFilePath()
)
|| !MethodAnalyzer::isMethodVisible(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ public static function analyze(
$callstatic_id,
$context->calling_function_id,
$codebase->collect_references ? new CodeLocation($source, $stmt->name) : null,
$statements_analyzer,
!$context->collect_initializations
&& !$context->collect_mutations
? $statements_analyzer
: null,
$statements_analyzer->getFilePath()
)) {
if (isset($class_storage->pseudo_static_methods[$method_name_lc])) {
Expand Down
23 changes: 16 additions & 7 deletions src/Psalm/Internal/Codebase/Methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,22 @@ public function methodExists(
return false;
}

if ($source && $fq_class_name !== strtolower((string) $source->getFQCLN())) {
$this->file_reference_provider->addFileReferenceToClass(
$source->getFilePath(),
$fq_class_name
);
}

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

if ((string) $calling_function_id === strtolower((string) $declaring_method_id)) {
return true;
}

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

if ($source && $declaring_fq_class_name !== strtolower((string) $source->getFQCLN())) {
$this->file_reference_provider->addFileReferenceToClass(
$source->getFilePath(),
$declaring_fq_class_name
);
}

if ((string) $method_id !== (string) $declaring_method_id
&& $class_storage->user_defined
&& isset($class_storage->potential_declaring_method_ids[$method_name])
Expand Down Expand Up @@ -235,6 +237,13 @@ public function methodExists(
return true;
}

if ($source && $fq_class_name !== strtolower((string) $source->getFQCLN())) {
$this->file_reference_provider->addFileReferenceToClass(
$source->getFilePath(),
$fq_class_name
);
}

if ($class_storage->abstract && isset($class_storage->overridden_method_ids[$method_name])) {
return true;
}
Expand Down

0 comments on commit 766effb

Please sign in to comment.