The reason PHPStorm is showing a warning about the Inertia::render() method expecting only 1 parameter, but you're providing 2, is likely due to the fact that the IDE's static analysis of the method signature doesn't match the actual implementation in the Inertia.js package you're using.
PHP Storm giving error for select, only one parameter allowed
class TestController extends Controller
{
public function index(): Response
{
$users = User::select('id', 'name')->get();
return Inertia::render('Test', ['users' => $users]);
}
}
Method call is provided 2 parameters, but the method signature uses 1 parameters
it is working in react and only showing the 2 parameters for users, but why would PHP storm say this? Thanks
See this part of the select method.
The method signature has only one parameter, hence the warning. But if the $columns argument is not an array, func_get_args() is used, which populates all arguments into an array. So the method works with an array argument as well as variadic arguments.
As to why they didn't use ...$columns in the signature, I'm not sure. You can't assign a default value to a variadic parameter. Maybe they wanted the default made explicit in the signature, or maybe they wanted the ability to distinquish between ->select() and ->select([]).
Please or to participate in this conversation.