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

[8.x] Fix Client\Response throw method #34597

Merged
merged 1 commit into from
Sep 30, 2020
Merged

[8.x] Fix Client\Response throw method #34597

merged 1 commit into from
Sep 30, 2020

Conversation

rodrigopedra
Copy link
Contributor

@rodrigopedra rodrigopedra commented Sep 30, 2020

Closes #34591


Commit d034e2c changed the Illuminate\Http\Client\Response@throw method to accept an optional callback. But code started failing when the throw method was being called without any parameters.

According to PHP docs on func_get_arg https://www.php.net/manual/en/function.func-get-arg.php

Generates a warning if called from outside of a user-defined function, or if arg_num is greater than the number of arguments actually passed.

This PR fixes that by changing that statement to $callback = func_get_args()[0] ?? null.

While testing locally I noticed the same commit also created an $exception variable inside a if block and throw it outside. In the case a $callback was not provided the code would fail due to a undefined $exception variable. This PR addresses that case too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Http::get('URL')->throw() will now throw "Argument 0 not passed to function"
2 participants