Fix notice: Array to string conversion
@sebheitzmann
Same on 4.2 To fix it see your log to more details
For example
There error Error: Data directory /var/lib/postgresql/14/main must not be owned by root
before createdb: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
error.
Now https://github.com/PHP-DI/Slim-Bridge/blob/master/src/Bridge.php#L44
$resolvers = [
// Inject parameters by name first
new AssociativeArrayResolver(),
// Then inject services by type-hints for those that weren't resolved
new TypeHintContainerResolver($container),
// Then fall back on parameters default values for optional route parameters
new DefaultValueResolver(),
];
The code
$app->post('/', [MyController::class, 'run'])
final class MyController
{
public function run(\App\Model\RpcRequest $request): Response
{
// ...
}
}
throws
TypeError
Argument 1 passed to App\MyController::run() must be an instance of \App\Model\RpcRequest, instance of Slim\Psr7\Request given
This looks more like a bug than consistent behavior, even though it has been documented. It is possible that this will lead to broken backward compatibility :/
Thanks for the clarification and your time.
App\Model\RpcRequest
could be a valid dto that has been checked and set in container on middleware level.
App\Model\RpcRequest
can be a valid dto that has been set in container as stateless objects the middleware.
Yea, it shouldn't be in a container. Bad example.
Now https://github.com/PHP-DI/Slim-Bridge/blob/master/src/Bridge.php#L44
$resolvers = [
// Inject parameters by name first
new AssociativeArrayResolver(),
// Then inject services by type-hints for those that weren't resolved
new TypeHintContainerResolver($container),
// Then fall back on parameters default values for optional route parameters
new DefaultValueResolver(),
];
The code
$app->post('/', [MyController::class, 'run'])
final class MyController
{
public function run(\App\Model\RpcRequest $request): Response
{
// ...
}
}
throws
TypeError
Argument 1 passed to App\MyController::run() must be an instance of \App\Model\RpcRequest, instance of Slim\Psr7\Request given
This looks more like a bug than consistent behavior, even though it has been documented. It is possible that this will lead to broken backward compatibility :/
Reordered $resolvers
To fix strict type of arguments
Added methods RouteCollector::createGroup and createProxy