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

Add third loop test

This commit is contained in:
Matt Brown 2017-03-13 11:53:16 -04:00
parent fa63afc27d
commit 20791bfae6

View File

@ -404,4 +404,31 @@ class LoopScopeTest extends PHPUnit_Framework_TestCase
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
$file_checker->visitAndAnalyzeMethods();
}
public function testThirdLoopWithIntCheckAndLoopSet()
{
$stmts = self::$parser->parse('<?php
/** @return void **/
function takesInt(int $i) {}
$a = null;
$b = null;
foreach ([1, 2, 3] as $i) {
if ($b !== null) {
takesInt($b);
}
if ($a !== null) {
takesInt($a);
$b = $a;
}
$a = $i;
}
');
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
$file_checker->visitAndAnalyzeMethods();
}
}