You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using RequestResponseArgs as the default invocation strategy, the $args parameter should always be an array, regardless of whether the route is inside a group.
Current Behavior:
When using RequestResponseArgs, $args is passed as a string instead of an array when the route is nested inside a group.
Steps to Reproduce:
Install Slim 4.12.0.
Set RequestResponseArgs as the default invocation strategy.
Define a nested route inside a group.
Access the route and observe that $args is passed as a string.
Minimal Reproducible Example:
<?php
require __DIR__ . '/vendor/autoload.php';
use Slim\Factory\AppFactory;
use Slim\Interfaces\RouteCollectorProxyInterface as RouteCollectorProxy;
use Slim\Handlers\Strategies\RequestResponseArgs;
$app = AppFactory::create();
// Set RequestResponseArgs strategy
$collector = $app->getRouteCollector();
$collector->setDefaultInvocationStrategy(new RequestResponseArgs());
$app->group('/goods', function (RouteCollectorProxy $group) {
$group->get('/{name}', function ($request, $response, array $args) {
var_dump($args); // Expect array, but it's a string
return $response;
});
});
$app->run();
Error Message:
Fatal error: Uncaught TypeError: Closure::{closure}(): Argument #3 ($args) must be of type array, string given
Possible Cause:
It seems that when {name} is inside a nested group, Slim fails to properly process the route parameters and passes them as a string instead of an array.
Workarounds:
Using RequestResponse instead of RequestResponseArgs
Expected Behavior:
When using RequestResponseArgs as the default invocation strategy, the $args parameter should always be an array, regardless of whether the route is inside a group.
Current Behavior:
When using RequestResponseArgs, $args is passed as a string instead of an array when the route is nested inside a group.
Steps to Reproduce:
Install Slim 4.12.0.
Set RequestResponseArgs as the default invocation strategy.
Define a nested route inside a group.
Access the route and observe that $args is passed as a string.
Minimal Reproducible Example:
Error Message:
Fatal error: Uncaught TypeError: Closure::{closure}(): Argument #3 ($args) must be of type array, string given
Possible Cause:
It seems that when {name} is inside a nested group, Slim fails to properly process the route parameters and passes them as a string instead of an array.
Workarounds:
$collector->setDefaultInvocationStrategy(new \Slim\Handlers\Strategies\RequestResponse());
$name = $request->getAttribute('name');
The text was updated successfully, but these errors were encountered: