Skip to content

Improve PHPDoc return type for synchronous HTTP Client methods - #58090

Merged
taylorotwell merged 2 commits into
laravel:12.xfrom
khaled-sadek:12.x
Dec 11, 2025
Merged

taylorotwell merged 2 commits into
laravel:12.xfrom
khaled-sadek:12.x

Conversation

@khaled-sadek

Copy link
Copy Markdown
Contributor

What is changed?

This PR updates the PHPDoc return type annotations for the synchronous methods on the Illuminate\Http\Client\PendingRequest class.

Methods affected include: get(), post(), put(), patch(), delete(), head(), and send().

Why is this necessary?

When using the Laravel HTTP Client for synchronous requests, static analysis tools (like PHPStan/Larastan) may incorrectly infer the return type as potentially including a GuzzleHttp\Promise\PromiseInterface object (which is the actual return type for the asynchronous/concurrent methods).

For synchronous calls (which is the default usage pattern), the method will always return an Illuminate\Http\Client\Response object.

By explicitly setting the return type to \Illuminate\Http\Client\Response, we prevent false-positive errors in static analysis, resulting in a cleaner development experience for users relying on type-checking.

This change aligns the documentation with the actual runtime behavior of the synchronous client calls.

@cosmastech

Copy link
Copy Markdown
Contributor

Nice! Thanks @khaled-sadek && @canvural

@taylorotwell
taylorotwell merged commit cf9078a into laravel:12.x Dec 11, 2025
70 checks passed
@iBotPeaches

Copy link
Copy Markdown
Contributor

The facade automated commit for this looks odd - a void now. Does it understand the if or am I out of my league understanding this?

d3d7c2e

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.

4 participants