From 41ea541084d097bb6d0a63a0e6e1f22fcbebb968 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 18:11:54 +0200 Subject: [PATCH] unset instead of reassign --- .../Internal/Analyzer/ClassLikeAnalyzer.php | 4 +-- src/Psalm/Internal/Analyzer/FileAnalyzer.php | 3 +- .../Internal/Analyzer/SourceAnalyzer.php | 2 +- .../Statements/Block/SwitchCaseAnalyzer.php | 28 ++++++++----------- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index 825d9a52a..f1b66b95e 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -106,8 +106,8 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer public function __destruct() { - $this->source = null; - $this->file_analyzer = null; + unset($this->source); + unset($this->file_analyzer); } public function getMethodMutations( diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index fe8c61beb..1e6a46c9e 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -662,7 +662,6 @@ class FileAnalyzer extends SourceAnalyzer public function clearSourceBeforeDestruction() : void { - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $this->source = null; + unset($this->source); } } diff --git a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php index 8e6739564..ba8d0c319 100644 --- a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php @@ -18,7 +18,7 @@ abstract class SourceAnalyzer implements StatementsSource public function __destruct() { - $this->source = null; + unset($this->source); } public function getAliases(): Aliases diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php index 920fd7e43..bbedadc6c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php @@ -98,10 +98,9 @@ class SwitchCaseAnalyzer $case_context->inside_conditional = true; if (ExpressionAnalyzer::analyze($statements_analyzer, $case->cond, $case_context) === false) { - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); return false; } @@ -273,10 +272,9 @@ class SwitchCaseAnalyzer $switch_scope->leftover_statements = [$case_if_stmt]; } - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); $statements_analyzer->node_data = $old_node_data; @@ -500,10 +498,9 @@ class SwitchCaseAnalyzer $case_exit_type, $switch_scope ) === false) { - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); return false; } @@ -558,10 +555,9 @@ class SwitchCaseAnalyzer } } - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); return null; }