mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
parent
61c979136f
commit
550ba0a4c9
@ -1071,7 +1071,6 @@ class IfAnalyzer
|
||||
);
|
||||
|
||||
$elseif_context = $if_conditional_scope->if_context;
|
||||
$original_context = $if_conditional_scope->original_context;
|
||||
$cond_referenced_var_ids = $if_conditional_scope->cond_referenced_var_ids;
|
||||
$cond_assigned_var_ids = $if_conditional_scope->cond_assigned_var_ids;
|
||||
$entry_clauses = $if_conditional_scope->entry_clauses;
|
||||
@ -1325,7 +1324,7 @@ class IfAnalyzer
|
||||
$if_scope->final_actions = array_merge($final_actions, $if_scope->final_actions);
|
||||
|
||||
// update the parent context as necessary
|
||||
$elseif_redefined_vars = $elseif_context->getRedefinedVars($original_context->vars_in_scope);
|
||||
$elseif_redefined_vars = $elseif_context->getRedefinedVars($outer_context->vars_in_scope);
|
||||
|
||||
if (!$has_leaving_statements) {
|
||||
if ($if_scope->new_vars === null) {
|
||||
|
@ -956,6 +956,56 @@ class TypeAlgebraTest extends \Psalm\Tests\TestCase
|
||||
if ($a) {}
|
||||
}'
|
||||
],
|
||||
'twoVarChangeInElseOnly' => [
|
||||
'<?php
|
||||
class A {
|
||||
public function takesA(A $a) : void {}
|
||||
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
function formatRange(?A $from, ?A $to): void {
|
||||
if (!$to && !$from) {
|
||||
$to = new A();
|
||||
$from = new A();
|
||||
} elseif (!$from) {
|
||||
$from = new A();
|
||||
$from->takesA($to);
|
||||
} else {
|
||||
if (!$to) {
|
||||
$to = new A();
|
||||
$to->takesA($from);
|
||||
}
|
||||
}
|
||||
|
||||
$from->foo();
|
||||
$to->foo();
|
||||
}'
|
||||
],
|
||||
'twoVarChangeInElseif' => [
|
||||
'<?php
|
||||
class A {
|
||||
public function takesA(A $a) : void {}
|
||||
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
function formatRange(?A $from, ?A $to): void {
|
||||
if (!$to && !$from) {
|
||||
$to = new A();
|
||||
$from = new A();
|
||||
} elseif (!$from) {
|
||||
$from = new A();
|
||||
$from->takesA($to);
|
||||
} elseif (!$to) {
|
||||
$to = new A();
|
||||
$to->takesA($from);
|
||||
}
|
||||
|
||||
$from->foo();
|
||||
$to->foo();
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user