mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Invalidate clauses when assigning root vars
This commit is contained in:
parent
3b4a7a97bc
commit
8ca5fbefea
@ -224,8 +224,6 @@ class LoopChecker
|
||||
unset($inner_context->vars_in_scope[$var_id]);
|
||||
}
|
||||
|
||||
$inner_context->clauses = $pre_loop_context->clauses;
|
||||
|
||||
IssueBuffer::startRecording();
|
||||
|
||||
foreach ($pre_conditions as $pre_condition) {
|
||||
@ -238,6 +236,8 @@ class LoopChecker
|
||||
);
|
||||
}
|
||||
|
||||
$inner_context->clauses = $pre_loop_context->clauses;
|
||||
|
||||
$statements_checker->analyze($stmts, $inner_context, $loop_scope);
|
||||
|
||||
self::updateLoopScopeContexts($loop_scope, $pre_outer_context);
|
||||
|
@ -372,6 +372,14 @@ class Context
|
||||
foreach ($clauses as $clause) {
|
||||
\Psalm\Checker\AlgebraChecker::calculateNegation($clause);
|
||||
|
||||
$quoted_remove_var_id = preg_quote($remove_var_id);
|
||||
|
||||
foreach ($clause->possibilities as $var_id => $_) {
|
||||
if (preg_match('/^' . $quoted_remove_var_id . '[\[\-]/', $var_id)) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($clause->possibilities[$remove_var_id]) ||
|
||||
$clause->possibilities[$remove_var_id] === [$new_type_string]
|
||||
) {
|
||||
|
@ -223,6 +223,15 @@ class RedundantConditionTest extends TestCase
|
||||
return 2;
|
||||
}',
|
||||
],
|
||||
'evaluateArrayCheck' => [
|
||||
'<?php
|
||||
function array_check() : void {
|
||||
$data = ["f" => false];
|
||||
while (rand(0, 1) > 0 && !$data["f"]) {
|
||||
$data = ["f" => true];
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user