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

Make project checker always aware of file paths to classes

This commit is contained in:
Matt Brown 2017-01-19 10:55:58 -05:00
parent a14b03c057
commit 0ba02f304f
5 changed files with 22 additions and 12 deletions

View File

@ -39,7 +39,7 @@ class ClassChecker extends ClassLikeChecker
$storage = self::$storage[$fq_class_name_lower];
$project_checker = $source->getFileChecker()->project_checker;
$project_checker->addFullyQualifiedClassName($fq_class_name);
$project_checker->addFullyQualifiedClassName($fq_class_name, $source->getFilePath());
self::$class_extends[$this->fq_class_name] = [];

View File

@ -1068,8 +1068,6 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
$storage = self::$storage[$class_name_lower] = new ClassLikeStorage();
$project_checker->addFullyQualifiedClassName($class_name);
self::$class_extends[$class_name] = [];
if ($reflected_parent_class) {

View File

@ -24,7 +24,7 @@ class InterfaceChecker extends ClassLikeChecker
$storage = self::$storage[$fq_interface_name_lower];
$project_checker = $source->getFileChecker()->project_checker;
$project_checker->addFullyQualifiedInterfaceName($fq_interface_name);
$project_checker->addFullyQualifiedInterfaceName($fq_interface_name, $source->getFilePath());
if ($interface->extends) {
foreach ($interface->extends as $extended_interface) {

View File

@ -543,14 +543,12 @@ class ProjectChecker
$this->existing_classlikes[$fq_class_name] = true;
if ($reflected_class->isInterface()) {
$this->addFullyQualifiedInterfaceName($fq_class_name);
$this->addFullyQualifiedInterfaceName($fq_class_name, (string)$reflected_class->getFileName());
} elseif ($reflected_class->isTrait()) {
$this->addFullyQualifiedTraitName($fq_class_name);
$this->addFullyQualifiedTraitName($fq_class_name, (string)$reflected_class->getFileName());
} else {
$this->addFullyQualifiedClassName($fq_class_name);
$this->addFullyQualifiedClassName($fq_class_name, (string)$reflected_class->getFileName());
}
$this->classlike_files[$fq_class_name] = (string)$reflected_class->getFileName();
} else {
$this->visited_classes[$fq_class_name] = true;
ClassLikeChecker::registerReflectedClass($reflected_class->name, $reflected_class, $this);
@ -850,7 +848,7 @@ class ProjectChecker
* @param string $fq_class_name
* @return void
*/
public function addFullyQualifiedClassName($fq_class_name)
public function addFullyQualifiedClassName($fq_class_name, $file_path = null)
{
$fq_class_name_ci = strtolower($fq_class_name);
$this->existing_classlikes_ci[$fq_class_name_ci] = true;
@ -858,13 +856,17 @@ class ProjectChecker
$this->existing_traits_ci[$fq_class_name_ci] = false;
$this->existing_interfaces_ci[$fq_class_name_ci] = false;
$this->existing_classes[$fq_class_name] = true;
if ($file_path) {
$this->classlike_files[$fq_class_name] = $file_path;
}
}
/**
* @param string $fq_class_name
* @return void
*/
public function addFullyQualifiedInterfaceName($fq_class_name)
public function addFullyQualifiedInterfaceName($fq_class_name, $file_path = null)
{
$fq_class_name_ci = strtolower($fq_class_name);
$this->existing_classlikes_ci[$fq_class_name_ci] = true;
@ -872,13 +874,17 @@ class ProjectChecker
$this->existing_classes_ci[$fq_class_name_ci] = false;
$this->existing_traits_ci[$fq_class_name_ci] = false;
$this->existing_interfaces[$fq_class_name] = true;
if ($file_path) {
$this->classlike_files[$fq_class_name] = $file_path;
}
}
/**
* @param string $fq_class_name
* @return void
*/
public function addFullyQualifiedTraitName($fq_class_name)
public function addFullyQualifiedTraitName($fq_class_name, $file_path = null)
{
$fq_class_name_ci = strtolower($fq_class_name);
$this->existing_classlikes_ci[$fq_class_name_ci] = true;
@ -886,6 +892,10 @@ class ProjectChecker
$this->existing_classes_ci[$fq_class_name_ci] = false;
$this->existing_interfaces_ci[$fq_class_name_ci] = false;
$this->existing_traits[$fq_class_name] = true;
if ($file_path) {
$this->classlike_files[$fq_class_name] = $file_path;
}
}
/**

View File

@ -40,6 +40,8 @@ class TraitChecker extends ClassLikeChecker
$fq_class_name_lower = strtolower($fq_class_name);
$project_checker = $source->getFileChecker()->project_checker;
if (!isset(self::$storage[$fq_class_name_lower])) {
self::$storage[$fq_class_name_lower] = $storage = new ClassLikeStorage();
$storage->file_name = $this->source->getFileName();