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

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

Closed
yateric opened this issue Sep 30, 2020 · 7 comments · Fixed by #34597
Closed

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

yateric opened this issue Sep 30, 2020 · 7 comments · Fixed by #34597

Comments

@yateric
Copy link
Contributor

yateric commented Sep 30, 2020

  • Laravel Version: 8.7.1
  • PHP Version: 7.4.10
  • Database Driver & Version: Not related

Description:

// framework/src/Illuminate/Http/Client/Response.php

public function throw()
{
    $callback = func_get_arg(0);

    if ($this->serverError() || $this->clientError()) {
        if ($callback && is_callable($callback)) {
            $callback($this, $exception = new RequestException($this));
        }

        throw $exception;
    }

    return $this;
}

It will throw Argument 0 not passed to function if no argument is passed.

Steps To Reproduce:

Http::get('https://www.laravel.com')->throw()->body();

This code will throw the Argument 0 not passed to function in Laravel 8.7.1

@MiniCodeMonkey
Copy link
Contributor

Thanks for reporting this. I also posted some details about it here: d034e2c#r42849328

@MiniCodeMonkey
Copy link
Contributor

Any reason not to do public function throw($callback = null) instead of using func_get_arg(0)?

@rodrigopedra
Copy link
Contributor

@MiniCodeMonkey , changing the method signature would be a breaking change for users that are extending this class, and as breaking change it would only be released on Laravel 9.

So the approach allows us to add this new feature without introducing a BC.

@MiniCodeMonkey
Copy link
Contributor

MiniCodeMonkey commented Sep 30, 2020 via email

@andrey-helldar
Copy link
Contributor

@taylorotwell, #34597 fix accepted. Tell me, when is the patch release planned?

@driesvints
Copy link
Member

@andrey-helldar releases are done on Tuesdays.

@andrey-helldar
Copy link
Contributor

image

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 a pull request may close this issue.

5 participants