mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
use cache for declared function when available before falling back to stubs
fixes return type issues reported for the wrong file
This commit is contained in:
parent
5bf59e4e9b
commit
e803af4cd4
@ -84,8 +84,9 @@ class Functions
|
|||||||
$function_id = substr($function_id, 1);
|
$function_id = substr($function_id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$from_stubs = false;
|
||||||
if (isset(self::$stubbed_functions[$function_id])) {
|
if (isset(self::$stubbed_functions[$function_id])) {
|
||||||
return self::$stubbed_functions[$function_id];
|
$from_stubs = self::$stubbed_functions[$function_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_storage = null;
|
$file_storage = null;
|
||||||
@ -117,6 +118,10 @@ class Functions
|
|||||||
return $this->reflection->getFunctionStorage($function_id);
|
return $this->reflection->getFunctionStorage($function_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($from_stubs) {
|
||||||
|
return $from_stubs;
|
||||||
|
}
|
||||||
|
|
||||||
throw new UnexpectedValueException(
|
throw new UnexpectedValueException(
|
||||||
'Expecting non-empty $root_file_path and $checked_file_path'
|
'Expecting non-empty $root_file_path and $checked_file_path'
|
||||||
);
|
);
|
||||||
@ -135,6 +140,10 @@ class Functions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($from_stubs) {
|
||||||
|
return $from_stubs;
|
||||||
|
}
|
||||||
|
|
||||||
throw new UnexpectedValueException(
|
throw new UnexpectedValueException(
|
||||||
'Expecting ' . $function_id . ' to have storage in ' . $checked_file_path
|
'Expecting ' . $function_id . ' to have storage in ' . $checked_file_path
|
||||||
);
|
);
|
||||||
@ -145,6 +154,10 @@ class Functions
|
|||||||
$declaring_file_storage = $this->file_storage_provider->get($declaring_file_path);
|
$declaring_file_storage = $this->file_storage_provider->get($declaring_file_path);
|
||||||
|
|
||||||
if (!isset($declaring_file_storage->functions[$function_id])) {
|
if (!isset($declaring_file_storage->functions[$function_id])) {
|
||||||
|
if ($from_stubs) {
|
||||||
|
return $from_stubs;
|
||||||
|
}
|
||||||
|
|
||||||
throw new UnexpectedValueException(
|
throw new UnexpectedValueException(
|
||||||
'Not expecting ' . $function_id . ' to not have storage in ' . $declaring_file_path
|
'Not expecting ' . $function_id . ' to not have storage in ' . $declaring_file_path
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user