mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Be more robust in the case of missing parent class
This commit is contained in:
parent
f614944b63
commit
de9d282205
@ -462,12 +462,15 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
||||
);
|
||||
|
||||
if (!$config->excludeIssueInFile('InvalidReturnType', $source->getFileName())) {
|
||||
$return_type_location = null;
|
||||
$secondary_return_type_location = null;
|
||||
|
||||
if ($actual_method_id) {
|
||||
$return_type_location = MethodChecker::getMethodReturnTypeLocation(
|
||||
$actual_method_id,
|
||||
$secondary_return_type_location
|
||||
);
|
||||
}
|
||||
|
||||
$method_checker->verifyReturnType(
|
||||
$update_docblocks,
|
||||
|
@ -89,9 +89,12 @@ class MethodChecker extends FunctionLikeChecker
|
||||
*/
|
||||
public static function getMethodReturnType($method_id)
|
||||
{
|
||||
/** @var string */
|
||||
$method_id = self::getDeclaringMethodId($method_id);
|
||||
|
||||
if (!$method_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
list($fq_class_name, $method_name) = explode('::', $method_id);
|
||||
|
||||
if (!ClassLikeChecker::isUserDefined($fq_class_name) && FunctionChecker::inCallMap($method_id)) {
|
||||
@ -134,9 +137,12 @@ class MethodChecker extends FunctionLikeChecker
|
||||
*/
|
||||
public static function getMethodReturnTypeLocation($method_id, CodeLocation &$defined_location = null)
|
||||
{
|
||||
/** @var string */
|
||||
$method_id = self::getDeclaringMethodId($method_id);
|
||||
|
||||
if ($method_id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$storage = self::getStorage($method_id);
|
||||
|
||||
if (!$storage) {
|
||||
@ -356,6 +362,10 @@ class MethodChecker extends FunctionLikeChecker
|
||||
|
||||
$fq_class_name_lower = strtolower($fq_class_name);
|
||||
|
||||
if (!isset(ClassLikeChecker::$storage[$fq_class_name_lower])) {
|
||||
throw new \UnexpectedValueException('$class_storage should not be null for ' . $method_id);
|
||||
}
|
||||
|
||||
$class_storage = ClassLikeChecker::$storage[$fq_class_name_lower];
|
||||
|
||||
if (!isset($class_storage->methods[strtolower($method_name)])) {
|
||||
|
Loading…
Reference in New Issue
Block a user