Skip to content
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

Uncaught InvalidArgumentException: Unsupported argument type #4

Closed
IvAil0 opened this issue Jun 18, 2021 · 1 comment
Closed

Uncaught InvalidArgumentException: Unsupported argument type #4

IvAil0 opened this issue Jun 18, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@IvAil0
Copy link

IvAil0 commented Jun 18, 2021

I use the example from: https://www.swoole.co.uk/article/swoole-and-psr
I use last verison of Slim4 (v4.8), PHP 8.0.6, swoole (v4.6.7), psr-swoole-native (v0.0.4)
If I make a POST or GET request with data everything works as it should, but when I make a request whether POST or GET without data (body) it returns an error:

Fatal error: Uncaught InvalidArgumentException: Unsupported argument type in /var/www/vendor/imefisto/psr-swoole-native/src/ServerRequest.php:99
Stack trace:
#0 /var/www/vendor/slim/slim/Slim/Middleware/BodyParsingMiddleware.php(65): Imefisto\PsrSwoole\ServerRequest->withParsedBody(NULL)
#1 /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\BodyParsingMiddleware->process(Object(Imefisto\PsrSwoole\ServerRequest), Object(Slim\Routing\RouteRunner))
#2 /var/www/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Imefisto\PsrSwoole\ServerRequest))
#3 /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\RoutingMiddleware->process(Object(Imefisto\PsrSwoole\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#4 /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Imefisto\PsrSwoole\ServerRequest))
#5 /var/www/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle(Object(Imefisto\PsrSwoole\ServerRequest))
#6 /var/www/cli/server.php(89): Slim\App->handle(Object(Imefisto\PsrSwoole\ServerRequest))
#7 {main}
thrown in /var/www/vendor/imefisto/psr-swoole-native/src/ServerRequest.php on line 99

@imefisto imefisto added the bug Something isn't working label Jun 19, 2021
@imefisto
Copy link
Owner

Good catch. The standard says the $data argument for the withParsedBody function can receive null:

Deserialization/parsing returns structured data, and, as such, this method ONLY accepts arrays or objects, or a null value if nothing was available to parse

I've added support for the case $data = null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants