New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestResponseArgs guess data types of args #2687
Comments
@bednic you can create your own strategy and set it on the $app = AppFactory::create();
$strategy = new MyCustomRouteInvocationStrategy();
// Do it for all routes
$routeCollector = $app->getRouteCollector();
$routeCollector->setDefaultRouteInvocationStrategy($strategy);
// Do it for one route only
$app->get('/', function (...) {...})->setInvocationStrategy($strategy); |
Yea I know, I can. It was just idea to enchant your strategy to make it more sexy. It doesn't mean it's bug or something. I'm just curious if you are even interested in this improvement and then if you approve this idea I can make some MR later. |
I'm not opposed to an improvement as long as it doesn't break the existing functionality. I suppose you'd have to do the parameter detection through reflection and there's going to be a lot of edge cases.. Definitely open to a PR if you want! |
Just to give my 2 cents, PHP-DI bridge does this thanks to his |
It's true, I used to use it in previous version of Slim. I didn't expect it will work with Slim 4, don't know why 🤨. But there is one tricky case with optional parameters. But I suppose it fits my requirement. I will try setup my skeleton with that. |
Again, feel free to PR this so we can add it to the library of route invocation strategies. I have no problems with it, it's never going to be the default strategy though. |
Slim-Bridge is adding support for Slim 4. I'm closing this as resolved. |
I have an idea about RequestResponseArgs handle strategy in Slim 4, it should be nice, if this strategy cast data types of args right. Like if I have method($request, $response, int $id, string $value), then this strategy cast first arg as int, second arg as string, if no data type is provided, then cast is as string.
The text was updated successfully, but these errors were encountered: