diff --git a/tests/TypeTest.php b/tests/TypeTest.php index e8a99ee7c..e0ce6041e 100644 --- a/tests/TypeTest.php +++ b/tests/TypeTest.php @@ -3,6 +3,7 @@ namespace Psalm\Tests; use Psalm\Type; +use Psalm\Context; use PhpParser; use PhpParser\ParserFactory; @@ -1099,6 +1100,53 @@ class TypeTest extends PHPUnit_Framework_TestCase $file_checker->check(); } + public function testUnionTypeFlowWithThrow() + { + $stmts = self::$_parser->parse('foo(); + } + '); + + $file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts); + $file_checker->check(); + } + + public function testUnionTypeFlowWithElseif() + { + $stmts = self::$_parser->parse('foo(); + } + '); + + $file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts); + $file_checker->check(); + } + /** * @expectedException Psalm\Exception\CodeException */ @@ -1130,15 +1178,6 @@ class TypeTest extends PHPUnit_Framework_TestCase public function foo() {} } - class Two { - public function bar() {} - } - - class Three { - public function baz() {} - } - - $var = new One(); if ($var instanceof One) { @@ -1403,4 +1442,43 @@ class TypeTest extends PHPUnit_Framework_TestCase $file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts); $file_checker->check(); } + + public function testAssignInsideForeach() + { + $stmts = self::$_parser->parse('check(true, true, $context); + + $this->assertSame('bool', (string) $context->vars_in_scope['b']); + } + + public function testAssignInsideForeachWithBreak() + { + $stmts = self::$_parser->parse('check(true, true, $context); + + $this->assertSame('bool', (string) $context->vars_in_scope['b']); + } }