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 Method B::fooFoo has more arguments than parent method A::fooFoo * @return void */ public function testMoreArguments() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage Method B::fooFoo has fewer arguments than parent method A::fooFoo * @return void */ public function testFewerArguments() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage Argument 1 of B::fooFoo has wrong type 'bool', expecting 'int' as defined by A::foo * @return void */ public function testDifferentArguments() { $stmts = self::$parser->parse('project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @return void */ public function testExtendDocblockParamType() { if (class_exists('SoapClient') === false) { $this->markTestSkipped( 'Cannot run test, base class "SoapClient" does not exist!' ); return; } $stmts = self::$parser->parse(' $arguments * @param array $options default null * @param array $input_headers default null * @param array $output_headers default null * @return mixed */ public function __soapCall( $function_name, $arguments, $options = [], $input_headers = [], &$output_headers = [] ) { } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage MethodSignatureMismatch * @return void */ public function testExtendDocblockParamTypeWithWrongParam() { if (class_exists('SoapClient') === false) { $this->markTestSkipped( 'Cannot run test, base class "SoapClient" does not exist!' ); return; } $stmts = self::$parser->parse(' $options default null * @param array $input_headers default null * @param array $output_headers default null * @return mixed */ public function __soapCall( $function_name, string $arguments, $options = [], $input_headers = [], &$output_headers = [] ) { } } '); $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } }