From 99da371ac459f6df6c6c45036f91f7d142e7d5b4 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sat, 28 Apr 2018 13:46:01 -0400 Subject: [PATCH] Move memoisation after callmap branch --- .../Expression/Call/MethodCallChecker.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Psalm/Checker/Statements/Expression/Call/MethodCallChecker.php b/src/Psalm/Checker/Statements/Expression/Call/MethodCallChecker.php index d033df6f6..3af57abb0 100644 --- a/src/Psalm/Checker/Statements/Expression/Call/MethodCallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/Call/MethodCallChecker.php @@ -582,18 +582,6 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker $context->getPhantomClasses() ); } - - if (!$stmt->args && $var_id) { - if ($config->memoize_method_calls) { - $method_var_id = $var_id . '->' . $method_name_lc . '()'; - - if (isset($context->vars_in_scope[$method_var_id])) { - $return_type_candidate = clone $context->vars_in_scope[$method_var_id]; - } else { - $context->vars_in_scope[$method_var_id] = $return_type_candidate; - } - } - } } else { $returns_by_ref = $returns_by_ref @@ -614,6 +602,18 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker } } + if (!$stmt->args && $var_id) { + if ($config->memoize_method_calls) { + $method_var_id = $var_id . '->' . $method_name_lc . '()'; + + if (isset($context->vars_in_scope[$method_var_id])) { + $return_type_candidate = clone $context->vars_in_scope[$method_var_id]; + } elseif ($return_type_candidate) { + $context->vars_in_scope[$method_var_id] = $return_type_candidate; + } + } + } + if ($config->after_method_checks) { $file_manipulations = [];