addFile( 'somefile.php', $code ); $file_checker = new FileChecker('somefile.php', $this->project_checker); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidScalarArgument * * @return void */ public function testVariadicArrayBadParam() { $this->addFile( 'somefile.php', ' $a_list * @return void */ function f(int ...$a_list) { } f(1, 2, "3"); ' ); $file_checker = new FileChecker('somefile.php', $this->project_checker); $context = new Context(); $file_checker->visitAndAnalyzeMethods($context); } /** * @return array */ public function providerTestValidVariadic() { return [ 'variadic' => [ ' $params * @return array */ function f($req, $opt = null, ...$params) { return $params; } f(1); f(1, 2); f(1, 2, 3); f(1, 2, 3, 4); f(1, 2, 3, 4, 5);', ], 'funcNumArgsVariadic' => [ ' [ ' $a_list * @return array */ function f(int ...$a_list) { return array_map( /** * @return int */ function (int $a) { return $a + 1; }, $a_list ); } f(1); f(1, 2); f(1, 2, 3); /** * @param string ...$a_list * @return void */ function g(string ...$a_list) { }', ], ]; } }