create(ParserFactory::PREFER_PHP7); $config = new TestConfig(); } /** * @return void */ public function setUp() { FileChecker::clearCache(); $this->project_checker = new \Psalm\Checker\ProjectChecker(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UndefinedClass * @return void */ public function testUndefinedClass() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidClass * @return void */ public function testWrongCaseClass() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidScope * @return void */ public function testInvalidThisFetch() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidScope * @return void */ public function testInvalidThisAssignment() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UndefinedConstant * @return void */ public function testUndefinedConstant() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UndefinedConstant * @return void */ public function testUndefinedClassConstant() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testSingleFileInheritance() { $stmts = self::$parser->parse('barBar(); } protected function barBar() : void { echo "hello"; } }'); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidParent * @return void */ public function testInheritanceLoopOne() { $this->markTestSkipped('A bug'); $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidParent * @return void */ public function testInheritanceLoopTwo() { $this->markTestSkipped('A bug'); $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidParent * @return void */ public function testInheritanceLoopThree() { $this->markTestSkipped('A bug'); $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testConstSandwich() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testDeferredReference() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); $this->assertEquals('int', (string) $context->vars_in_scope['$a']); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UndefinedConstant * @return void */ public function testInvalidDeferredReference() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testMoreCyclicalReferences() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testReferenceToSubclassInMethod() { $stmts = self::$parser->parse('c(); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testReferenceToClassInMethod() { $stmts = self::$parser->parse('b(new A()); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage OverriddenMethodAccess * @return void */ public function testOverridePublicAccessLevelToPrivate() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage OverriddenMethodAccess * @return void */ public function testOverridePublicAccessLevelToProtected() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage OverriddenMethodAccess * @return void */ public function testOverrideProtectedAccessLevelToPrivate() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testOverrideProtectedAccessLevelToPublic() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context('somefile.php'); $file_checker->visitAndAnalyzeMethods($context); } }