1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add for post conditions to assignment map analysis

This commit is contained in:
Matthew Brown 2017-12-13 22:04:37 -05:00
parent 298ee214e9
commit 34c133d5d0
2 changed files with 14 additions and 1 deletions

View File

@ -40,7 +40,7 @@ class LoopChecker
$assignment_mapper = new \Psalm\Visitor\AssignmentMapVisitor($loop_scope->loop_context->self);
$traverser->addVisitor($assignment_mapper);
$traverser->traverse($stmts);
$traverser->traverse(array_merge($stmts, $post_conditions));
$assignment_map = $assignment_mapper->getAssignmentMap();

View File

@ -188,6 +188,19 @@ class RedundantConditionTest extends TestCase
$ch = curl_init();
if (!$ch) {}',
],
'noRedundantConditionInForCheck' => [
'<?php
class Node
{
/** @var Node|null */
public $next;
public function iterate(): void
{
for ($node = $this; $node !== null; $node = $node->next) {}
}
}',
],
];
}