create(ParserFactory::PREFER_PHP7); self::$project_dir = getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR; } /** * @return void */ public function setUp() { FileChecker::clearCache(); $this->project_checker = new \Psalm\Checker\ProjectChecker(); $this->project_checker->setConfig(Config::loadFromXML( 'psalm.xml', ' ' )); $this->project_checker->count_references = true; } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UnusedVariable * @return void */ public function testFunction() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UnusedVariable * @return void */ public function testIfInFunction() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testUnset() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UnusedClass * @return void */ public function testUnusedClass() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); $this->project_checker->checkClassReferences(); } /** * @return void */ public function testPublicUnusedMethod() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); $this->project_checker->checkClassReferences(); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage UnusedMethod * @return void */ public function testPrivateUnusedMethod() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); $this->project_checker->checkClassReferences(); } }