mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Improve clause resolution in while loops
This commit is contained in:
parent
965a79251d
commit
7f8a3d798e
@ -29,12 +29,18 @@ class WhileChecker
|
||||
return false;
|
||||
}
|
||||
|
||||
$while_types = AssertionFinder::getAssertions(
|
||||
$while_clauses = TypeChecker::getFormula(
|
||||
$stmt->cond,
|
||||
$statements_checker->getFQCLN(),
|
||||
$context->self,
|
||||
$statements_checker
|
||||
);
|
||||
|
||||
$while_context->clauses = TypeChecker::simplifyCNF(array_merge($context->clauses, $while_clauses));
|
||||
|
||||
$negated_clauses = TypeChecker::negateFormula($while_clauses);
|
||||
|
||||
$reconcilable_while_types = TypeChecker::getTruthsFromFormula($while_context->clauses);
|
||||
|
||||
// if the while has an or as the main component, we cannot safely reason about it
|
||||
if ($stmt->cond instanceof PhpParser\Node\Expr\BinaryOp &&
|
||||
$stmt->cond instanceof PhpParser\Node\Expr\BinaryOp\BooleanOr
|
||||
@ -44,7 +50,7 @@ class WhileChecker
|
||||
$changed_vars = [];
|
||||
|
||||
$while_vars_in_scope_reconciled = TypeChecker::reconcileKeyedTypes(
|
||||
$while_types,
|
||||
$reconcilable_while_types,
|
||||
$while_context->vars_in_scope,
|
||||
$changed_vars,
|
||||
$statements_checker->getFileChecker(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user