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

Include use references to classes in reference collection

This commit is contained in:
Matthew Brown 2017-02-28 00:29:28 -05:00
parent b948198ca9
commit f55c754eab
3 changed files with 18 additions and 3 deletions

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -52,7 +52,7 @@ trait CanAlias
// register the path
$project_checker = $this->getFileChecker()->project_checker;
$project_checker->use_referencing_locations[$use_path][$this->getFilePath()] =
$project_checker->use_referencing_locations[strtolower($use_path)][$this->getFilePath()][] =
new \Psalm\CodeLocation($this, $use);
}

View File

@ -157,7 +157,7 @@ class ProjectChecker
/**
* A map of fully-qualified use declarations to the files
* that reference them (keyed by filename)
* @var array<string, array<string, array<int, CodeLocation>>>
* @var array<string, array<string, array<int, \Psalm\CodeLocation>>>
*/
public $use_referencing_locations = [];
@ -409,7 +409,22 @@ class ProjectChecker
die('No references found for ' . $fq_class_name . PHP_EOL);
}
return $class_storage->referencing_locations;
$classlike_references_by_file = $class_storage->referencing_locations;
if (isset($this->use_referencing_locations[strtolower($fq_class_name)])) {
foreach ($this->use_referencing_locations[strtolower($fq_class_name)] as $file_path => $locations) {
if (!isset($classlike_references_by_file[$file_path])) {
$classlike_references_by_file[$file_path] = $locations;
} else {
$classlike_references_by_file[$file_path] = array_merge(
$locations,
$classlike_references_by_file[$file_path]
);
}
}
}
return $classlike_references_by_file;
}
/**