markTestSkipped('Cannot run test, base class "SoapClient" does not exist!'); return; } $this->addFile( 'somefile.php', ' $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 = [] ) { return $_GET["foo"]; } }' ); $this->analyzeFile('somefile.php', new 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; } $this->addFile( 'somefile.php', ' $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 = [] ) { } }' ); $this->analyzeFile('somefile.php', new Context()); } /** * @return array */ public function providerValidCodeParse() { return [ 'privateArgs' => [ ' [ 'foo(null);', ], 'nullableSubclassParamWithDefault' => [ 'foo();', ], 'allowSubclassesForNonInheritedMethodParams' => [ 'bar(); }', ], 'allowNoReturnInSubclassWithNullableReturnType' => [ ' [ ' [ ' [ '$b' => 'B', ], ], 'allowSomeCovariance' => [ ' [ ' [ 'id, ] = (array) \unserialize((string) $serialized); } public function serialize() : string { return serialize([$this->id]); } }', ], 'clashWithCallMapClass' => [ ' [ ' [ ' [ ' [ ' [ ' 'Method B::fooFoo has more required parameters than parent method A::fooFoo', ], 'fewerArguments' => [ ' 'Method B::fooFoo has fewer parameters than parent method A::fooFoo', ], 'differentArguments' => [ ' 'Argument 1 of B::fooFoo has wrong type \'bool\', expecting \'int\' as defined ' . 'by A::fooFoo', ], 'nonNullableSubclassParam' => [ ' 'Argument 1 of B::foo has wrong type \'string\', expecting \'string|null\' as', ], 'mismatchingCovariantReturn' => [ ' 'MethodSignatureMismatch', ], 'mismatchingCovariantReturnWithSelf' => [ ' 'MethodSignatureMismatch', ], 'misplacedRequiredParam' => [ ' 'MisplacedRequiredParam', ], 'clasginByRef' => [ ' 'MethodSignatureMismatch', ], 'disallowSubclassesForNonInheritedMethodParams' => [ 'bar(); } }', 'error_message' => 'MoreSpecificImplementedParamType', ], 'disallowVoidToNullConversionSignature' => [ ' 'MethodSignatureMismatch', ], 'abstractExtendsNonAbstractWithMethod' => [ ' 'MethodSignatureMismatch', ], 'traitReturnTypeMismatch' => [ ' 'ImplementedReturnTypeMismatch', ], 'abstractTraitMethodWithDifferentReturnType' => [ ' 'ImplementedReturnTypeMismatch' ], 'mustOmitReturnType' => [ ' 'MethodSignatureMustOmitReturnType', ], 'requireParam' => [ ' 'MethodSignatureMismatch - src/somefile.php:6 - Method C::foo has more required', ], 'inheritParamTypes' => [ 'foo(new stdClass);', 'error_message' => 'InvalidArgument' ], 'interfaceHasFewerConstructorArgs' => [ ' 'MethodSignatureMismatch', ], ]; } }