1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 01:09:38 +01:00

unset instead of reassign

This commit is contained in:
orklah 2021-09-25 18:11:54 +02:00
parent 06da96843a
commit 41ea541084
4 changed files with 16 additions and 21 deletions

View File

@ -106,8 +106,8 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer
public function __destruct() public function __destruct()
{ {
$this->source = null; unset($this->source);
$this->file_analyzer = null; unset($this->file_analyzer);
} }
public function getMethodMutations( public function getMethodMutations(

View File

@ -662,7 +662,6 @@ class FileAnalyzer extends SourceAnalyzer
public function clearSourceBeforeDestruction() : void public function clearSourceBeforeDestruction() : void
{ {
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */ unset($this->source);
$this->source = null;
} }
} }

View File

@ -18,7 +18,7 @@ abstract class SourceAnalyzer implements StatementsSource
public function __destruct() public function __destruct()
{ {
$this->source = null; unset($this->source);
} }
public function getAliases(): Aliases public function getAliases(): Aliases

View File

@ -98,10 +98,9 @@ class SwitchCaseAnalyzer
$case_context->inside_conditional = true; $case_context->inside_conditional = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $case->cond, $case_context) === false) { if (ExpressionAnalyzer::analyze($statements_analyzer, $case->cond, $case_context) === false) {
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */ unset($case_scope->parent_context);
$case_scope->parent_context = null; unset($case_context->case_scope);
$case_context->case_scope = null; unset($case_context->parent_context);
$case_context->parent_context = null;
return false; return false;
} }
@ -273,10 +272,9 @@ class SwitchCaseAnalyzer
$switch_scope->leftover_statements = [$case_if_stmt]; $switch_scope->leftover_statements = [$case_if_stmt];
} }
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */ unset($case_scope->parent_context);
$case_scope->parent_context = null; unset($case_context->case_scope);
$case_context->case_scope = null; unset($case_context->parent_context);
$case_context->parent_context = null;
$statements_analyzer->node_data = $old_node_data; $statements_analyzer->node_data = $old_node_data;
@ -500,10 +498,9 @@ class SwitchCaseAnalyzer
$case_exit_type, $case_exit_type,
$switch_scope $switch_scope
) === false) { ) === false) {
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */ unset($case_scope->parent_context);
$case_scope->parent_context = null; unset($case_context->case_scope);
$case_context->case_scope = null; unset($case_context->parent_context);
$case_context->parent_context = null;
return false; return false;
} }
@ -558,10 +555,9 @@ class SwitchCaseAnalyzer
} }
} }
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */ unset($case_scope->parent_context);
$case_scope->parent_context = null; unset($case_context->case_scope);
$case_context->case_scope = null; unset($case_context->parent_context);
$case_context->parent_context = null;
return null; return null;
} }