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

Created on 30 Sep 2020  Â·  7Comments  Â·  Source: laravel/framework


  • 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

Most helpful comment

@andrey-helldar releases are done on Tuesdays.

All 7 comments

Thanks for reporting this. I also posted some details about it here: https://github.com/laravel/framework/commit/d034e2c55c6502fa0c2bebb6cbf99c5e685beaa5#r42849328

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

@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.

Ah. That totally makes sense. Thanks for clarifying!

On September 30, 2020, GitHub notifications@github.com wrote:

@MiniCodeMonkey https://github.com/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.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
701435463>, or unsubscribe
auth/AABV254UJIE5TOTYXDNCL3TSIM7QNANCNFSM4R6RCOSQ>.

@taylorotwell, https://github.com/laravel/framework/pull/34597 fix accepted. Tell me, when is the patch release planned?

@andrey-helldar releases are done on Tuesdays.

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iivanov2 picture iivanov2  Â·  3Comments

YannPl picture YannPl  Â·  3Comments

digirew picture digirew  Â·  3Comments

Fuzzyma picture Fuzzyma  Â·  3Comments

lzp819739483 picture lzp819739483  Â·  3Comments