Skip to content

Commit

Permalink
remove unused function, fix unusedVariable error after suppress
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Nov 13, 2023
1 parent 6a0a9d1 commit 88e3cda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,15 @@ public static function analyze(
$statements_analyzer->getSuppressedIssues(),
)) {
// if the error is suppressed, do not treat it as never anymore
$context->vars_in_scope[$var_id] = Type::getMixed();
$new_mutable = $context->vars_in_scope[$var_id]->getBuilder()->addType(new TMixed);
$new_mutable->removeType('never');
$context->vars_in_scope[$var_id] = $new_mutable->freeze();
$context->has_returned = false;
}

$context->inside_assignment = $was_in_assignment;
} else {
$context->inside_assignment = $was_in_assignment;

return $context->vars_in_scope[$var_id];
return $context->vars_in_scope[$var_id];
}
}

if ($statements_analyzer->data_flow_graph) {
Expand Down
5 changes: 1 addition & 4 deletions tests/UnusedCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1332,10 +1332,6 @@ public function b(): void {}
*/
function foo() : void {}
function bar(mixed $s) : string {
return is_string($s) ? "hello" : "world";
}
/** @psalm-suppress NoValue */
$a = foo();
print_r($a);',
Expand All @@ -1349,6 +1345,7 @@ function bar(mixed $s) : string {
*/
function foo() : void {}
/** @psalm-suppress UnusedParam */
function bar(mixed $s) : void {}
/** @psalm-suppress NoValue */
Expand Down

0 comments on commit 88e3cda

Please sign in to comment.