1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Don’t cache no-effects hashes when checking for initialisations

This commit is contained in:
Brown 2020-02-04 17:53:26 -05:00
parent 4c83ca75b3
commit 8fb810350a

View File

@ -175,11 +175,13 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
$appearing_class_storage = $classlike_storage_provider->get($fq_class_name); $appearing_class_storage = $classlike_storage_provider->get($fq_class_name);
if ($add_mutations) { 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 we know that the function has no effects on vars, we don't bother rechecking
if (isset(self::$no_effects_hashes[$hash])) { if (isset(self::$no_effects_hashes[$hash])) {
return null; return null;
}
} }
} elseif ($context->self) { } elseif ($context->self) {
if ($appearing_class_storage->template_types) { 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()); $new_hash = md5($real_method_id . '::' . $context->getScopeSummary());
if ($new_hash === $hash) { if ($new_hash === $hash) {