create(ParserFactory::PREFER_PHP7); $config = \Psalm\Config::getInstance(); $config->throw_exception = true; } public function setUp() { \Psalm\Checker\FileChecker::clearCache(); } public function testNewVarInIf() { $stmts = self::$_parser->parse('foo = []; } if (!is_array($this->foo)) { // do something } } } '); $file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts); $file_checker->check(); } public function testSharedPropertyInIf() { $stmts = self::$_parser->parse('foo; } '); $file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts); $context = new Context('somefile.php'); $file_checker->check(true, true, $context); $this->assertEquals('null|string|int', (string) $context->vars_in_scope['b']); } public function testSharedPropertyInElseIf() { $stmts = self::$_parser->parse('foo; } '); $file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts); $context = new Context('somefile.php'); $file_checker->check(true, true, $context); $this->assertEquals('null|string|int', (string) $context->vars_in_scope['b']); } }