diff --git a/src/Psalm/Checker/ClassLikeChecker.php b/src/Psalm/Checker/ClassLikeChecker.php index c3d577b9d..878497a2c 100644 --- a/src/Psalm/Checker/ClassLikeChecker.php +++ b/src/Psalm/Checker/ClassLikeChecker.php @@ -318,6 +318,8 @@ abstract class ClassLikeChecker implements StatementsSource return self::$method_checkers[$method_id]; } + ClassMethodChecker::registerClassMethod($method_id); + $declaring_method_id = ClassMethodChecker::getDeclaringMethod($method_id); $declaring_class = explode('::', $declaring_method_id)[0]; @@ -329,10 +331,11 @@ abstract class ClassLikeChecker implements StatementsSource foreach ($class_checker->class->stmts as $stmt) { if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod) { - $method_checker = new ClassMethodChecker($stmt, $class_checker); - $method_id = $class_checker->absolute_class . '::' . $stmt->name; - self::$method_checkers[$method_id] = $method_checker; - return $method_checker; + if ($declaring_method_id === $class_checker->absolute_class . '::' . $stmt->name) { + $method_checker = new ClassMethodChecker($stmt, $class_checker); + self::$method_checkers[$method_id] = $method_checker; + return $method_checker; + } } } diff --git a/src/Psalm/Checker/ClassMethodChecker.php b/src/Psalm/Checker/ClassMethodChecker.php index 28c67fc51..fd3c5b9e5 100644 --- a/src/Psalm/Checker/ClassMethodChecker.php +++ b/src/Psalm/Checker/ClassMethodChecker.php @@ -259,7 +259,7 @@ class ClassMethodChecker extends FunctionLikeChecker } } - protected static function registerClassMethod($method_id) + public static function registerClassMethod($method_id) { ClassLikeChecker::registerClass(explode('::', $method_id)[0]); } diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index edd670a23..427d29e55 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -57,7 +57,6 @@ abstract class FunctionLikeChecker implements StatementsSource // if we know that the function has no effects on vars, we don't bother rechecking if (isset(self::$no_effects_hashes[$hash])) { list($context->vars_in_scope, $context->vars_possibly_in_scope) = self::$no_effects_hashes[$hash]; - return; } }