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

Static property fetching is bad

This commit is contained in:
Matthew Brown 2020-08-23 13:10:47 -04:00 committed by Daniil Gentili
parent 8589e4af55
commit 9d6939226e
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -176,6 +176,8 @@ class StaticPropertyFetchAnalyzer
);
}
$project_analyzer = $statements_analyzer->getProjectAnalyzer();
if ($context->mutation_free) {
if (IssueBuffer::accepts(
new \Psalm\Issue\ImpureStaticProperty(
@ -186,6 +188,12 @@ class StaticPropertyFetchAnalyzer
)) {
// fall through
}
} elseif ($codebase->alter_code
&& isset($project_analyzer->getIssuesToFix()['MissingPureAnnotation'])
&& $statements_analyzer->getSource()
instanceof \Psalm\Internal\Analyzer\FunctionLikeAnalyzer
) {
$statements_analyzer->getSource()->inferred_impure = true;
}
if ($var_id && $context->hasVariable($var_id, $statements_analyzer)) {