From 8fb810350a1c93e05a4f74b7433dc9c92c6e4504 Mon Sep 17 00:00:00 2001 From: Brown Date: Tue, 4 Feb 2020 17:53:26 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20cache=20no-effects=20hashes=20w?= =?UTF-8?q?hen=20checking=20for=20initialisations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Internal/Analyzer/FunctionLikeAnalyzer.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 544aacee2..ace982734 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -175,11 +175,13 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $appearing_class_storage = $classlike_storage_provider->get($fq_class_name); if ($add_mutations) { - $hash = md5($real_method_id . '::' . $context->getScopeSummary()); + if (!$context->collect_initializations) { + $hash = md5($real_method_id . '::' . $context->getScopeSummary()); - // if we know that the function has no effects on vars, we don't bother rechecking - if (isset(self::$no_effects_hashes[$hash])) { - return null; + // if we know that the function has no effects on vars, we don't bother rechecking + if (isset(self::$no_effects_hashes[$hash])) { + return null; + } } } elseif ($context->self) { if ($appearing_class_storage->template_types) { @@ -735,7 +737,11 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer } } - if ($hash && $real_method_id && $this instanceof MethodAnalyzer) { + if ($hash + && $real_method_id + && $this instanceof MethodAnalyzer + && !$context->collect_initializations + ) { $new_hash = md5($real_method_id . '::' . $context->getScopeSummary()); if ($new_hash === $hash) {