create(ParserFactory::PREFER_PHP7); $config = Config::getInstance(); $config->throw_exception = true; $config->use_docblock_types = true; } public function setUp() { FileChecker::clearCache(); } public function testConstArray() { $stmts = self::$parser->parse('check(true, true, $context); $this->assertEquals('string', (string) $context->vars_in_scope['$a']); } public function testConstFeatures() { $stmts = self::$parser->parse('f(); $e = C::SENTENCE; $f = TWO; $g = C::ONE_THIRD; '); $file_checker = new FileChecker('somefile.php', $stmts); $context = new Context('somefile.php'); $file_checker->check(true, true, $context); $this->assertEquals('int', (string) $context->vars_in_scope['$d']); $this->assertEquals('string', (string) $context->vars_in_scope['$e']); $this->assertEquals('int', (string) $context->vars_in_scope['$f']); $this->assertEquals('float', (string) $context->vars_in_scope['$g']); } public function testVariadic() { $stmts = self::$parser->parse('check(true, true, $context); } public function testVariadicArray() { $stmts = self::$parser->parse(' */ function f(int ...$a_list) { return array_map(function (int $a) { return $a + 1; }, $a_list); } f(1); f(1, 2); f(1, 2, 3); '); $file_checker = new FileChecker('somefile.php', $stmts); $context = new Context('somefile.php'); $file_checker->check(true, true, $context); } public function testArgumentUnpacking() { $stmts = self::$parser->parse('check(true, true, $context); } public function testExponentiation() { $stmts = self::$parser->parse('check(true, true, $context); } public function testConstantAliasInNamespace() { $stmts = self::$parser->parse('check(true, true, $context); } public function testConstantAliasInClass() { $stmts = self::$parser->parse('check(true, true, $context); } public function testFunctionAliasInNamespace() { $stmts = self::$parser->parse('check(true, true, $context); } public function testFunctionAliasInClass() { $stmts = self::$parser->parse('check(true, true, $context); } }