1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +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,15 +1434,19 @@ class CallChecker
$offset_value_type = Type::parseString($arg->value->value); $offset_value_type = Type::parseString($arg->value->value);
} }
if ($offset_value_type) {
foreach ($offset_value_type->types as $offset_value_type_part) {
// register class if the class exists // register class if the class exists
if ($offset_value_type instanceof TNamedObject) { if ($offset_value_type_part instanceof TNamedObject) {
ClassLikeChecker::checkFullyQualifiedClassLikeName( ClassLikeChecker::checkFullyQualifiedClassLikeName(
$offset_value_type->value, $offset_value_type_part->value,
$statements_checker->getFileChecker(), $statements_checker->getFileChecker(),
new CodeLocation($statements_checker->getSource(), $arg->value), new CodeLocation($statements_checker->getSource(), $arg->value),
$statements_checker->getSuppressedIssues() $statements_checker->getSuppressedIssues()
); );
} }
}
}
if ($generic_params === null) { if ($generic_params === null) {
$generic_params = []; $generic_params = [];