create(ParserFactory::PREFER_PHP7); self::$config = new TestConfig(); } /** * @return void */ public function setUp() { FileChecker::clearCache(); $this->project_checker = new \Psalm\Checker\ProjectChecker(); $this->project_checker->setConfig(self::$config); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleMethod * @return void */ public function testInaccessiblePrivateMethod() { $stmts = self::$parser->parse('fooFoo(); '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleMethod * @return void */ public function testInaccessibleProtectedMethod() { $stmts = self::$parser->parse('fooFoo(); '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessiblePrivateMethodFromSubclass() { $stmts = self::$parser->parse('fooFoo(); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleMethod * @return void */ public function testInaccessiblePrivateMethodFromSubclass() { $stmts = self::$parser->parse('fooFoo(); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessibleProtectedMethodFromSubclass() { $stmts = self::$parser->parse('fooFoo(); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessibleProtectedMethodFromOtherSubclass() { $stmts = self::$parser->parse('fooFoo(); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleMethod * @return void */ public function testInaccessibleProtectedMethodFromOtherSubclass() { $stmts = self::$parser->parse('fooFoo(); } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleProperty * @return void */ public function testInaccessiblePrivateProperty() { $stmts = self::$parser->parse('fooFoo; '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleProperty * @return void */ public function testInaccessibleProtectedProperty() { $stmts = self::$parser->parse('fooFoo; '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleProperty * @return void */ public function testInaccessiblePrivatePropertyFromSubclass() { $stmts = self::$parser->parse('fooFoo; } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleProperty * @return void */ public function testInaccessibleStaticPrivateProperty() { $stmts = self::$parser->parse('project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleProperty * @return void */ public function testInaccessibleStaticProtectedProperty() { $stmts = self::$parser->parse('project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InaccessibleProperty * @return void */ public function testInaccessibleStaticPrivatePropertyFromSubclass() { $stmts = self::$parser->parse('project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessibleProtectedPropertyFromSubclass() { $stmts = self::$parser->parse('fooFoo; } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessibleProtectedPropertyFromGreatGrandparent() { $stmts = self::$parser->parse('fooFoo; } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessibleProtectedPropertyFromOtherSubclass() { $stmts = self::$parser->parse('fooFoo = "hello"; } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } /** * @return void */ public function testAccessibleStaticPropertyFromSubclass() { $stmts = self::$parser->parse('project_checker, $stmts); $file_checker->visitAndAnalyzeMethods(); } }