create(ParserFactory::PREFER_PHP7); $config = new TestConfig(); } /** * @return void */ public function setUp() { FileChecker::clearCache(); $this->project_checker = new \Psalm\Checker\ProjectChecker(); } /** * @return void */ public function testExtendsAndImplements() { $stmts = self::$parser->parse('baz(); $dee = (new D())->fooFoo(); ?> '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); $this->assertEquals('string', (string) $context->vars_in_scope['$cee']); $this->assertEquals('string', (string) $context->vars_in_scope['$dee']); } /** * @return void */ public function testIsExtendedInterface() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testExtendsWithMethod() { $stmts = self::$parser->parse('fooFoo(); } ?> '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage NoInterfaceProperties * @return void */ public function testNoInterfaceProperties() { $stmts = self::$parser->parse('bar) { } } ?> '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UnimplementedInterfaceMethod * @return void */ public function testUnimplementedInterfaceMethod() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MethodSignatureMismatch * @return void */ public function testMismatchingInterfaceMethodSignature() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testCorrectInterfaceMethodSignature() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testInterfaceMethodImplementedInParent() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MethodSignatureMismatch * @return void */ public function testMismatchingInterfaceMethodSignatureInTrait() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testInterfaceMethodSignatureInTrait() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MethodSignatureMismatch * @return void */ public function testMismatchingInterfaceMethodSignatureInImplementer() { $stmts = self::$parser->parse(' '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testDelayedInterface() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UndefinedClass * @return void */ public function testInvalidImplements() { $this->project_checker->registerFile( getcwd() . '/somefile.php', 'project_checker); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testTypeDoesNotContainType() { $stmts = self::$parser->parse('foo(); } }'); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testAbstractInterfaceImplements() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UnimplementedInterfaceMethod * @return void */ public function testAbstractInterfaceImplementsWithSubclass() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } }