1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix references

This commit is contained in:
Matt Brown 2017-02-27 16:38:43 -05:00
parent 07c9cfb848
commit 4f597a4068
2 changed files with 16 additions and 10 deletions

View File

@ -1067,11 +1067,13 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
* *
* @param string $fq_class_name * @param string $fq_class_name
* @param FileChecker $file_checker * @param FileChecker $file_checker
* @param CodeLocation $code_location
* @return bool * @return bool
*/ */
public static function classOrInterfaceExists( public static function classOrInterfaceExists(
$fq_class_name, $fq_class_name,
FileChecker $file_checker FileChecker $file_checker,
CodeLocation $code_location = null
) { ) {
if (!ClassChecker::classExists($fq_class_name, $file_checker) && if (!ClassChecker::classExists($fq_class_name, $file_checker) &&
!InterfaceChecker::interfaceExists($fq_class_name, $file_checker) !InterfaceChecker::interfaceExists($fq_class_name, $file_checker)
@ -1079,7 +1081,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
return false; return false;
} }
if ($file_checker->project_checker->collect_references) { if ($file_checker->project_checker->collect_references && $code_location) {
$class_storage = ClassLikeChecker::$storage[strtolower($fq_class_name)]; $class_storage = ClassLikeChecker::$storage[strtolower($fq_class_name)];
$class_storage->referencing_locations[] = $code_location; $class_storage->referencing_locations[] = $code_location;
} }

View File

@ -1434,14 +1434,18 @@ class CallChecker
$offset_value_type = Type::parseString($arg->value->value); $offset_value_type = Type::parseString($arg->value->value);
} }
// register class if the class exists if ($offset_value_type) {
if ($offset_value_type instanceof TNamedObject) { foreach ($offset_value_type->types as $offset_value_type_part) {
ClassLikeChecker::checkFullyQualifiedClassLikeName( // register class if the class exists
$offset_value_type->value, if ($offset_value_type_part instanceof TNamedObject) {
$statements_checker->getFileChecker(), ClassLikeChecker::checkFullyQualifiedClassLikeName(
new CodeLocation($statements_checker->getSource(), $arg->value), $offset_value_type_part->value,
$statements_checker->getSuppressedIssues() $statements_checker->getFileChecker(),
); new CodeLocation($statements_checker->getSource(), $arg->value),
$statements_checker->getSuppressedIssues()
);
}
}
} }
if ($generic_params === null) { if ($generic_params === null) {