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

[11.x] Add ResponseInterface mixin to Illuminate\Http\Client\Response #52410

Conversation

einar-hansen
Copy link
Contributor

This PR adds the Psr\Http\Message\ResponseInterface interface as a mixin to the Response class. This will make our IDE completion better.

/**
 * @mixin \Psr\Http\Message\ResponseInterface
 */

The Response class is using the magic __call method and forwards it calls to the $response property, therefore all the methods on the $response property is available for the developer.

    /**
     * The underlying PSR response.
     *
     * @var \Psr\Http\Message\ResponseInterface
     */
    protected $response;

    public function __call($method, $parameters)
    {
        return static::hasMacro($method)
                    ? $this->macroCall($method, $parameters)
                    : $this->response->{$method}(...$parameters);
    }

@einar-hansen einar-hansen force-pushed the fix/add-mixin-to-http-client-response-class branch from 2f35c41 to 0465644 Compare August 7, 2024 07:55
@taylorotwell taylorotwell merged commit fd0f381 into laravel:11.x Aug 7, 2024
59 checks passed
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.

2 participants