Open
Description
Hi!
I'd like to use php-di to inject route parameters. In my case these are always of type int
.
Using this function signature ...
$app->delete("/objects/{objectId}", [MyController::class, 'deleteObject']); // Please ignore the fake callable setup, this is just for demonstration
// ...
public function deleteObject(Request $request, Response $response, int $objectId)
... and then calling the path of this function with this URL: DELETE /objects/testing/
...
... produces a standard PHP exception: Argument 4 passed to App\\Controllers\\v2\\DocumentClassController::deleteTableField() must be of the type int, string given
I do understand why this happens and of course I could remove the int
type from the function signature and perform my own validation. But' maybe I am missing a more elegant way to catch this exception and automatically respond with a 400
status code.